This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] small patch to command_line_handler


Please check this carefully because I don't really understand the code here.

I'm trying to track down some memory trashing and random crashes and the 
command line handler is reading memory it didn't allocate, which is mostly 
harmless, but annoying and bad programming.  So here's a proposed fix.

-- 
Martin Hunt
GDB Engineer
Red Hat, Inc.

2002-06-07  Martin M. Hunt  <hunt@redhat.com>

	* event-top.c (command_line_handler): Don't read past
	beginning of buffer.

Index: event-top.c
===================================================================
RCS file: /cvs/src/src/gdb/event-top.c,v
retrieving revision 1.20
diff -u -u -r1.20 event-top.c
--- event-top.c	27 Mar 2002 21:20:15 -0000	1.20
+++ event-top.c	7 Jun 2002 20:08:32 -0000
@@ -681,7 +681,7 @@
 
   xfree (rl);			/* Allocated in readline.  */
 
-  if (*(p - 1) == '\\')
+  if (p > linebuffer && *(p - 1) == '\\')
     {
       p--;			/* Put on top of '\'.  */
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]