mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-24 14:00:30 +00:00
Remove memory leak in fdopen (bug 31840)
Deallocate the memory for the FILE structure when seeking to the end fails
in append mode.
Fixes: ea33158c96
("Fix offset caching for streams and use it for ftell (BZ #16680)")
This commit is contained in:
parent
1d441791cb
commit
b2c3ee3724
@ -156,8 +156,12 @@ _IO_new_fdopen (int fd, const char *mode)
|
|||||||
{
|
{
|
||||||
off64_t new_pos = _IO_SYSSEEK (&new_f->fp.file, 0, _IO_seek_end);
|
off64_t new_pos = _IO_SYSSEEK (&new_f->fp.file, 0, _IO_seek_end);
|
||||||
if (new_pos == _IO_pos_BAD && errno != ESPIPE)
|
if (new_pos == _IO_pos_BAD && errno != ESPIPE)
|
||||||
|
{
|
||||||
|
_IO_un_link (&new_f->fp);
|
||||||
|
free (new_f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return &new_f->fp.file;
|
return &new_f->fp.file;
|
||||||
}
|
}
|
||||||
libc_hidden_ver (_IO_new_fdopen, _IO_fdopen)
|
libc_hidden_ver (_IO_new_fdopen, _IO_fdopen)
|
||||||
|
Loading…
Reference in New Issue
Block a user