Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Cc: Thiago Jung Bauermann <bauerman@br.ibm.com>
Subject: [obv] Fix crash in c_get_string
Date: Tue, 14 Apr 2009 22:02:00 -0000	[thread overview]
Message-ID: <20090414220233.GA9093@host0.dyn.jankratochvil.net> (raw)

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));
 	}


             reply	other threads:[~2009-04-14 22:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-14 22:02 Jan Kratochvil [this message]
2009-04-14 22:59 ` Thiago Jung Bauermann
2009-04-15 17:43 ` Tom Tromey
2009-04-15 17:53   ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090414220233.GA9093@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=bauerman@br.ibm.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox