This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Ping [Patch libiberty]: Fix memory leak in ada demangler
> > 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. I didn't say you
didn't need to free the pointer, just that it's never going to be NULL
so the check for NULL is not needed. The code need only be this:
if (! changed)
{
free (demangled);
return NULL;
}
else
return demangled;