MFC r197752:
Better glibc compatibility for getline/getdelim: - Tolerate applications that pass a NULL pointer for the buffer and claim that the capacity of the buffer is nonzero. - If an application passes in a non-NULL buffer pointer and claims the buffer has zero capacity, we should free (well, realloc) it anyway. It could have been obtained from malloc(0), so failing to free it would be a small memory leak.
This commit is contained in:
parent
eb63bf5c83
commit
903d5593ab
@ -120,8 +120,8 @@ getdelim(char ** __restrict linep, size_t * __restrict linecapp, int delim,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (*linecapp == 0)
|
||||
*linep = NULL;
|
||||
if (*linep == NULL)
|
||||
*linecapp = 0;
|
||||
|
||||
if (fp->_r <= 0 && __srefill(fp)) {
|
||||
/* If fp is at EOF already, we just need space for the NUL. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user