public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libelf: decompress: ensure zlib resource cleanup
@ 2020-03-15 22:03 Matthias Maennich
  2020-03-15 23:10 ` Mark Wielaard
  2020-03-20 11:17 ` [PATCH v2] libelf: {de,}compress: " Matthias Maennich
  0 siblings, 2 replies; 9+ messages in thread
From: Matthias Maennich @ 2020-03-15 22:03 UTC (permalink / raw)
  To: elfutils-devel; +Cc: kernel-team, maennich

__libelf_decompress would only cleanup zlib resources via inflateEnd()
in case inflating was successful, but would leak memory if not. Fix this
by calling inflateEnd() in the error case as well.

Fixes: 272018bba1f2 ("libelf: Add elf_compress and elf_compress_gnu.")
Signed-off-by: Matthias Maennich <maennich@google.com>
---
 libelf/elf_compress.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libelf/elf_compress.c b/libelf/elf_compress.c
index 244467b5e3ae..beb1834bbbd7 100644
--- a/libelf/elf_compress.c
+++ b/libelf/elf_compress.c
@@ -257,6 +257,7 @@ __libelf_decompress (void *buf_in, size_t size_in, size_t size_out)
   if (unlikely (zrc != Z_OK) || unlikely (z.avail_out != 0))
     {
       free (buf_out);
+      inflateEnd(&z);
       __libelf_seterrno (ELF_E_DECOMPRESS_ERROR);
       return NULL;
     }
-- 
2.25.1.481.gfbce0eb801-goog


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-04-27  8:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-15 22:03 [PATCH] libelf: decompress: ensure zlib resource cleanup Matthias Maennich
2020-03-15 23:10 ` Mark Wielaard
2020-03-15 23:42   ` Matthias Maennich
2020-03-16 12:05     ` Mark Wielaard
2020-03-16 12:18       ` Mark Wielaard
2020-03-20 11:17 ` [PATCH v2] libelf: {de,}compress: " Matthias Maennich
2020-03-20 17:10   ` Mark Wielaard
2020-04-24 23:28   ` Mark Wielaard
2020-04-27  8:14     ` Matthias Maennich

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).