If pos >= count but realloc fails, tmp will not have been placed in
getnames[pos] yet, and so will not be freed in free_null. Detected
by Coverity.
Also remove misleading comment from nis_getnames(), since it actually
did properly release getnames when out of memory.
Tested-by: Carlos O'Donell <carlos@redhat.com>
return count;
}
-/* If we run out of memory, we don't give already allocated memory
- free. The overhead for bringing getnames back in a safe state to
- free it is to big. */
nis_name *
nis_getnames (const_nis_name name)
{
nis_name *newp = realloc (getnames,
(count + 1) * sizeof (char *));
if (__glibc_unlikely (newp == NULL))
- goto free_null;
+ {
+ free (tmp);
+ goto free_null;
+ }
getnames = newp;
}
getnames[pos] = tmp;