This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: Ping [Patch libiberty]: Fix memory leak in ada demangler


DJ Delorie wrote:
>>> Looks like demangled can't be NULL at that point.
>> Why ?
> 
> Because it's unconditionally dereferenced just before that point:
> 
>   for (i = 0; demangled[i] != '\0'; i += 1)
>     if (ISUPPER ((unsigned char)demangled[i]) || demangled[i] == ' ')
>       goto Suppress;
> 
>   if (! changed)
>     return NULL;
>   else
>     return demangled;
> 
> So if you add a check for demangled==NULL, the case it checks for
> would cause a segfault before you get to the check.  

  (Making the implicit explicit):  And will therefore be optimised out (at any
non-zero -O level) anyway unless you add `-fno-delete-null-pointer-checks' to
the CFLAGS.

    cheers,
      DaveK


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