* [PATCH] libelf: Fix memory leak when zlib deflateInit fails in elf_compress.
@ 2016-04-14 19:11 Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2016-04-14 19:11 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 1043 bytes --]
On error we return NULL, not out_buf. So make sure to not leak it.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
libelf/ChangeLog | 5 +++++
libelf/elf_compress.c | 1 +
2 files changed, 6 insertions(+)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 350e4eb..668687d 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,8 @@
+2016-04-14 Mark Wielaard <mjw@redhat.com>
+
+ * elf_compress.c (__libelf_compress): Free out_buf if deflateInit
+ fails.
+
2016-02-13 Mark Wielaard <mjw@redhat.com>
* elf32_updatefile.c (updatemmap): Free scns when out of memory.
diff --git a/libelf/elf_compress.c b/libelf/elf_compress.c
index 4c7c35e..10574ea 100644
--- a/libelf/elf_compress.c
+++ b/libelf/elf_compress.c
@@ -117,6 +117,7 @@ __libelf_compress (Elf_Scn *scn, size_t hsize, int ei_data,
int zrc = deflateInit (&z, Z_BEST_COMPRESSION);
if (zrc != Z_OK)
{
+ free (out_buf);
__libelf_seterrno (ELF_E_COMPRESS_ERROR);
return NULL;
}
--
2.5.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] libelf: Fix memory leak when zlib deflateInit fails in elf_compress.
@ 2016-04-25 11:46 Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2016-04-25 11:46 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 146 bytes --]
On Thu, 2016-04-14 at 21:11 +0200, Mark Wielaard wrote:
> On error we return NULL, not out_buf. So make sure to not leak it.
Pushed to master.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-25 11:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-14 19:11 [PATCH] libelf: Fix memory leak when zlib deflateInit fails in elf_compress Mark Wielaard
2016-04-25 11:46 Mark Wielaard
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).