This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [commit] dwarf2read.c (typename_concat): avoid segv
- From: Daniel Jacobowitz <drow at false dot org>
- To: Doug Evans <dje at google dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 24 Oct 2008 14:43:01 -0400
- Subject: Re: [commit] dwarf2read.c (typename_concat): avoid segv
- References: <20081024182614.58B191C7947@localhost>
On Fri, Oct 24, 2008 at 11:26:14AM -0700, Doug Evans wrote:
> Hi. I checked in the following as obvious.
> Running a large app with many shared libs under gdb -r caused gdb to segv.
Shouldn't this be in the affected caller? I thought we wouldn't reach
here if prefix or suffix are NULL.
> 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
If NULL values are valid, this change is definitely not correct.
You've changed a NULL prefix and "foo" suffix from "foo" to "::foo".
--
Daniel Jacobowitz
CodeSourcery