From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21178 invoked by alias); 24 Oct 2008 18:26:58 -0000 Received: (qmail 21168 invoked by uid 22791); 24 Oct 2008 18:26:58 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 24 Oct 2008 18:26:22 +0000 Received: from wpaz21.hot.corp.google.com (wpaz21.hot.corp.google.com [172.24.198.85]) by smtp-out.google.com with ESMTP id m9OIQFVj003646 for ; Fri, 24 Oct 2008 19:26:16 +0100 Received: from localhost (ruffy.corp.google.com [172.18.118.116]) by wpaz21.hot.corp.google.com with ESMTP id m9OIQEc2001006 for ; Fri, 24 Oct 2008 11:26:14 -0700 Received: by localhost (Postfix, from userid 67641) id 58B191C7947; Fri, 24 Oct 2008 11:26:14 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [commit] dwarf2read.c (typename_concat): avoid segv Message-Id: <20081024182614.58B191C7947@localhost> Date: Fri, 24 Oct 2008 18:26:00 -0000 From: dje@google.com (Doug Evans) 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: 2008-10/txt/msg00609.txt.bz2 Hi. I checked in the following as obvious. Running a large app with many shared libs under gdb -r caused gdb to segv. 2008-10-24 Doug Evans * dwarf2read.c (typename_concat): Don't segv if prefix or suffix is NULL. Simplify obs == NULL case. Index: dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.289 diff -u -p -r1.289 dwarf2read.c --- dwarf2read.c 10 Oct 2008 16:15:42 -0000 1.289 +++ dwarf2read.c 24 Oct 2008 18:12:01 -0000 @@ -8081,19 +8081,17 @@ typename_concat (struct obstack *obs, co else sep = "::"; + if (prefix == NULL) + prefix = ""; + if (suffix == NULL) + suffix = ""; + if (obs == NULL) { char *retval = xmalloc (strlen (prefix) + MAX_SEP_LEN + strlen (suffix) + 1); - retval[0] = '\0'; - - if (prefix) - { - strcpy (retval, prefix); - strcat (retval, sep); - } - if (suffix) - strcat (retval, suffix); - + strcpy (retval, prefix); + strcat (retval, sep); + strcat (retval, suffix); return retval; } else