2008-03-02 Jim Meyering <meyering@redhat.com>
+ * lib/getdelim.c (getdelim): Don't leak memory upon failed realloc.
+
Remove useless "if" tests before free. Deprecate "free" module.
* doc/posix-functions/free.texi: Mention that this
module is no longer useful.
if (*lineptr == NULL || *n == 0)
{
+ char *new_lineptr;
*n = 120;
- *lineptr = (char *) realloc (*lineptr, *n);
- if (*lineptr == NULL)
+ new_lineptr = (char *) realloc (*lineptr, *n);
+ if (new_lineptr == NULL)
{
result = -1;
goto unlock_return;
}
+ *lineptr = new_lineptr;
}
for (;;)