From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32686 invoked by alias); 24 Oct 2008 18:57:05 -0000 Received: (qmail 32675 invoked by uid 22791); 24 Oct 2008 18:57:05 -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:56:30 +0000 Received: from zps78.corp.google.com (zps78.corp.google.com [172.25.146.78]) by smtp-out.google.com with ESMTP id m9OIuLbW015381 for ; Fri, 24 Oct 2008 19:56:22 +0100 Received: from rv-out-0708.google.com (rvbf25.prod.google.com [10.140.82.25]) by zps78.corp.google.com with ESMTP id m9OItpoK029337 for ; Fri, 24 Oct 2008 11:56:20 -0700 Received: by rv-out-0708.google.com with SMTP id f25so878824rvb.26 for ; Fri, 24 Oct 2008 11:56:19 -0700 (PDT) Received: by 10.140.132.3 with SMTP id f3mr1385778rvd.277.1224874579906; Fri, 24 Oct 2008 11:56:19 -0700 (PDT) Received: by 10.141.99.20 with HTTP; Fri, 24 Oct 2008 11:56:19 -0700 (PDT) Message-ID: Date: Fri, 24 Oct 2008 18:57:00 -0000 From: "Doug Evans" To: gdb-patches@sourceware.org Subject: Re: [commit] dwarf2read.c (typename_concat): avoid segv In-Reply-To: <20081024184719.GA8460@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20081024182614.58B191C7947@localhost> <20081024184301.GA7759@caradoc.them.org> <20081024184719.GA8460@caradoc.them.org> 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/msg00614.txt.bz2 On Fri, Oct 24, 2008 at 11:47 AM, Daniel Jacobowitz wrote: > On Fri, Oct 24, 2008 at 02:43:01PM -0400, Daniel Jacobowitz wrote: >> If NULL values are valid, this change is definitely not correct. >> You've changed a NULL prefix and "foo" suffix from "foo" to "::foo". > > "Definitely" is too strong... I see that we differed with and without > an obstack :-( Heh. After I sent the message I knew I should have added a followup pointing out that the segv is in the obs != NULL case. Blech. typename_concat has this: /* Return a newly-allocated string formed by concatenating PREFIX and SUFFIX with appropriate separator. If PREFIX or SUFFIX is NULL or empty, then simply copy the SUFFIX or PREFIX, respectively. If OBS is non-null, perform an obconcat, otherwise allocate storage for the result. The CU argument is used to determine the language and hence, the appropriate separator. */ #define MAX_SEP_LEN 2 /* sizeof ("::") */ static char * typename_concat (struct obstack *obs, const char *prefix, const char *suffix, struct dwarf2_cu *cu) { char *sep; if (suffix == NULL || suffix[0] == '\0' || prefix == NULL || prefix[0] == '\0') sep = ""; else if (cu->language == language_java) sep = "."; else sep = "::"; Given that, I think my patch is correct (unless one wants to require callers to not pass NULL any longer). Am I missing something?