From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19852 invoked by alias); 14 Apr 2009 22:02:52 -0000 Received: (qmail 19701 invoked by uid 22791); 14 Apr 2009 22:02:51 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 14 Apr 2009 22:02:43 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n3EM2cHM017305; Tue, 14 Apr 2009 18:02:38 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n3EM2cF7009754; Tue, 14 Apr 2009 18:02:38 -0400 Received: from host0.dyn.jankratochvil.net (sebastian-int.corp.redhat.com [172.16.52.221]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n3EM2akL032343; Tue, 14 Apr 2009 18:02:37 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id n3EM2ann010499; Wed, 15 Apr 2009 00:02:36 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.2/Submit) id n3EM2Xpt010494; Wed, 15 Apr 2009 00:02:33 +0200 Date: Tue, 14 Apr 2009 22:02:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Cc: Thiago Jung Bauermann Subject: [obv] Fix crash in c_get_string Message-ID: <20090414220233.GA9093@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-04/txt/msg00284.txt.bz2 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 * 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)); }