]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libelf: Fix memory leak when zlib deflateInit fails in elf_compress.
authorMark Wielaard <mjw@redhat.com>
Thu, 14 Apr 2016 19:02:39 +0000 (21:02 +0200)
committerMark Wielaard <mjw@redhat.com>
Thu, 14 Apr 2016 19:08:30 +0000 (21:08 +0200)
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
libelf/elf_compress.c

index 350e4eb19207edd5264074ca3d1b681ebb459f42..668687db02f934b6f108e83b1168d41a9a39a977 100644 (file)
@@ -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.
index 4c7c35e1bd5f1818ad6e6645af91edf08da0c7cd..10574eaed26def885a4d6b7badf4e0d4161ea1e0 100644 (file)
@@ -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;
     }