public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Keith Seitz <keiths@redhat.com>
Cc: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [RFA] Change to pre-expand symtabs
Date: Sat, 04 Sep 2010 20:48:00 -0000	[thread overview]
Message-ID: <20100904134451.GA6173@host1.dyn.jankratochvil.net> (raw)
In-Reply-To: <4C7FFC68.8080702@redhat.com>

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

  reply	other threads:[~2010-09-04 13:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-26 18:47 Keith Seitz
2010-07-29 20:52 ` Tom Tromey
2010-07-30 16:48   ` Keith Seitz
2010-09-01 21:44 ` Tom Tromey
2010-09-02 17:28   ` Keith Seitz
2010-09-02 22:13   ` Keith Seitz
2010-09-04 20:48     ` Jan Kratochvil [this message]
2010-09-08 17:17       ` Keith Seitz

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=20100904134451.GA6173@host1.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    --cc=tromey@redhat.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).