This is the mail archive of the gdb-patches@sourceware.org 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]

[obv] Fix crash in c_get_string


Hi,

during a failed string read - as when pretty-printing uninitialized
std::string - GDB could crash.

I have a testcase requiring GDB pretty-printing which is not in FSF GDB now so
the test should get in later.  Did not check how to reproduce it more easily.

Checked-in as: http://sourceware.org/ml/gdb-cvs/2009-04/msg00077.html

Original bugreport at: https://bugzilla.redhat.com/show_bug.cgi?id=495781

read_string comment:
   Unless an exception is thrown, BUFFER will always be allocated, even on 
   failure.


Regards,
Jan


gdb/
2009-04-14  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* c-lang.c (c_get_string): Fix xfree crash on a failed string read.

--- src/gdb/c-lang.c	2009/03/21 00:46:17	1.63
+++ src/gdb/c-lang.c	2009/04/14 21:54:33	1.64
@@ -657,7 +657,7 @@
 			 buffer, length);
       if (err)
 	{
-	  xfree (buffer);
+	  xfree (*buffer);
 	  error (_("Error reading string from inferior: %s"),
 		 safe_strerror (err));
 	}


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