public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] Remove memory leak in fdopen (bug 31840)
@ 2024-06-04 12:52 Andreas Schwab
0 siblings, 0 replies; only message in thread
From: Andreas Schwab @ 2024-06-04 12:52 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b2c3ee3724900975deaf5eae57640bb0c2d7315e
commit b2c3ee3724900975deaf5eae57640bb0c2d7315e
Author: Andreas Schwab <schwab@suse.de>
Date: Tue Jun 4 11:01:11 2024 +0200
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)")
Diff:
---
libio/iofdopen.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libio/iofdopen.c b/libio/iofdopen.c
index 2583fb8255..14fbc7b257 100644
--- a/libio/iofdopen.c
+++ b/libio/iofdopen.c
@@ -156,7 +156,11 @@ _IO_new_fdopen (int fd, const char *mode)
{
off64_t new_pos = _IO_SYSSEEK (&new_f->fp.file, 0, _IO_seek_end);
if (new_pos == _IO_pos_BAD && errno != ESPIPE)
- return NULL;
+ {
+ _IO_un_link (&new_f->fp);
+ free (new_f);
+ return NULL;
+ }
}
return &new_f->fp.file;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-06-04 12:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-04 12:52 [glibc] Remove memory leak in fdopen (bug 31840) Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).