This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [commit] dwarf2read.c (typename_concat): avoid segv


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]