This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[obv] Fix crash in c_get_string
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: Thiago Jung Bauermann <bauerman at br dot ibm dot com>
- Date: Wed, 15 Apr 2009 00:02:33 +0200
- Subject: [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));
}