The source code is here: https://github.com/bminor/glibc/blob/master/libio/iofdopen.c
As shown in the iofdopen.c
, line 122 of the code creates a new_f
object with malloc
new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE));
but it does not call free(new_f)
before returns as line 159
/* For append mode, set the file offset to the end of the file if we added
O_APPEND to the file descriptor flags. Don't update the offset cache
though, since the file handle is not active. */
if (do_seek && ((read_write & (_IO_IS_APPENDING | _IO_NO_READS))
== (_IO_IS_APPENDING | _IO_NO_READS)))
{
off64_t new_pos = _IO_SYSSEEK (&new_f->fp.file, 0, _IO_seek_end);
if (new_pos == _IO_pos_BAD && errno != ESPIPE)
return NULL;
}
Is there a memory leak bug here?