Author: cfinck
Date: Fri Mar 19 01:00:42 2010
New Revision: 46269
URL: http://svn.reactos.org/svn/reactos?rev=46269&view=rev
Log:
Proper fix for the valgrind-detected error. Always null-terminates the line now before regular string functions are used.
Modified:
trunk/tools/sysreg2/console.c
Modified: trunk/tools/sysreg2/console.c
URL: http://svn.reactos.org/svn/reactos/trunk/tools/sysreg2/console.c?rev=46269&…
==============================================================================
--- trunk/tools/sysreg2/console.c [iso-8859-1] (original)
+++ trunk/tools/sysreg2/console.c [iso-8859-1] Fri Mar 19 01:00:42 2010
@@ -25,8 +25,7 @@
/* Initialize CacheBuffer with an empty string */
*CacheBuffer = 0;
- memset(Buffer, 0, BUFFER_SIZE);
-
+
/* ttyfd is the file descriptor of the virtual COM port */
if ((ttyfd = open(tty, O_NOCTTY | O_RDWR)) < 0)
{
@@ -112,17 +111,15 @@
}
else
{
- /* Also break on newlines */
- if(*bp == '\n')
+ /* Null-terminate the line */
+ bp[1] = 0;
+
+ /* Break on newlines or in case of KDBG messages (which aren't terminated by newlines) */
+ if(*bp == '\n' || strstr(Buffer, "kdb:>") || strstr(Buffer, "--- Press q"))
break;
- /* KDBG doesn't send a newline */
- if ((strstr(Buffer, "kdb:>")) ||
- (strstr(Buffer, "--- Press q")))
- break;
- }
-
- ++bp;
+ ++bp;
+ }
}
/* The rest of this logic is just about processing the serial output */
@@ -137,9 +134,6 @@
Ret = EXIT_CONTINUE;
goto cleanup;
}
-
- /* Null-terminate the line */
- *(++bp) = 0;
/* Detect whether the same line appears over and over again.
If that is the case, cancel this test after a specified number of repetitions. */