From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29504 invoked by alias); 4 Sep 2010 13:45:03 -0000 Received: (qmail 29439 invoked by uid 22791); 4 Sep 2010 13:45:02 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 04 Sep 2010 13:44:56 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o84DisIB020893 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 4 Sep 2010 09:44:55 -0400 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o84DiqpD022983 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 4 Sep 2010 09:44:54 -0400 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o84DiqCB006938; Sat, 4 Sep 2010 15:44:52 +0200 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o84DipPp006937; Sat, 4 Sep 2010 15:44:51 +0200 Date: Sat, 04 Sep 2010 20:48:00 -0000 From: Jan Kratochvil To: Keith Seitz Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [RFA] Change to pre-expand symtabs Message-ID: <20100904134451.GA6173@host1.dyn.jankratochvil.net> References: <4C4DD835.7060702@redhat.com> <4C7FFC68.8080702@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4C7FFC68.8080702@redhat.com> User-Agent: Mutt/1.5.20 (2009-12-10) 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: 2010-09/txt/msg00139.txt.bz2 On Thu, 02 Sep 2010 21:35:04 +0200, Keith Seitz wrote: > --- symtab.c 1 Sep 2010 21:50:26 -0000 1.252 > +++ symtab.c 2 Sep 2010 19:25:25 -0000 > +psymtab_search_name (const char *name) > + { > + static char *ret = NULL; > + > + if (ret != NULL) > + { > + xfree (ret); > + ret = NULL; > + } > + > + if (strchr (name, '(')) > + ret = cp_remove_params (name); > + > + return (ret == NULL) ? name : ret; > + } [...] > + const char *psym_search_name = psymtab_search_name (name); > sym = objfile->sf->qf->expand_one_symtab_matching (objfile, > block_index, > - name, domain, > + psym_search_name, > + domain, > match_symbol_aux, > objfile); I find such static buffer as needlessly dangerous, in general, without thinking too much more. I do not see obviously why some the callee expand_one_symtab_matching could not recursively call this function (incl. psymtab_search_name again) while still accessing also its passed parameter, which gets freed this way. I would just say the caller should xfree the string. (Yes, it is a pain to do make_cleanup if appropriate but that part is a different problem.) Thanks, Jan