This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Change to pre-expand symtabs
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Keith Seitz <keiths at redhat dot com>
- Cc: Tom Tromey <tromey at redhat dot com>, gdb-patches at sourceware dot org
- Date: Sat, 4 Sep 2010 15:44:51 +0200
- Subject: Re: [RFA] Change to pre-expand symtabs
- References: <4C4DD835.7060702@redhat.com> <m34oe9b150.fsf@fleche.redhat.com> <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