]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Fix sig8_hash memory leak in libdw/dwarf_begin_elf.c on error.
authorMark Wielaard <mjw@redhat.com>
Tue, 18 Dec 2012 13:14:22 +0000 (14:14 +0100)
committerMark Wielaard <mjw@redhat.com>
Tue, 18 Dec 2012 22:04:04 +0000 (23:04 +0100)
Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdw/ChangeLog
libdw/dwarf_begin_elf.c

index 0d35ca91a9d97416bd92c3cdbad530c18fe7421c..24f4bb488d17c1b3116594728a881e7ff5271512 100644 (file)
@@ -1,3 +1,10 @@
+2012-12-18  Mark Wielaard  <mjw@redhat.com>
+
+       * dwarf_begin_elf.c (valid_p): Call Dwarf_Sig8_Hash_free if invalid.
+       (check_section): Likewise on error.
+       (scngrp_read): Likewise.
+       (dwarf_begin_elf): Likewise.
+
 2012-10-09  Petr Machata  <pmachata@redhat.com>
 
        * dwarf_getlocation.c (__libdw_intern_expression): Handle
index a9c826ced7cc05e60adc44617f484d3539b993f3..6cf3aa17855df880e879c6881285bbcf43f15114 100644 (file)
@@ -216,6 +216,7 @@ check_section (Dwarf *result, GElf_Ehdr *ehdr, Elf_Scn *scn, bool inscngrp)
       /* The section name must be valid.  Otherwise is the ELF file
         invalid.  */
       __libdw_free_zdata (result);
+      Dwarf_Sig8_Hash_free (&result->sig8_hash);
       __libdw_seterrno (DWARF_E_INVALID_ELF);
       free (result);
       return NULL;
@@ -344,6 +345,7 @@ valid_p (Dwarf *result)
       && unlikely (result->sectiondata[IDX_debug_info] == NULL))
     {
       __libdw_free_zdata (result);
+      Dwarf_Sig8_Hash_free (&result->sig8_hash);
       __libdw_seterrno (DWARF_E_NO_DWARF);
       free (result);
       result = NULL;
@@ -375,6 +377,7 @@ scngrp_read (Dwarf *result, Elf *elf, GElf_Ehdr *ehdr, Elf_Scn *scngrp)
     {
       /* We cannot read the section content.  Fail!  */
       __libdw_free_zdata (result);
+      Dwarf_Sig8_Hash_free (&result->sig8_hash);
       free (result);
       return NULL;
     }
@@ -391,6 +394,7 @@ scngrp_read (Dwarf *result, Elf *elf, GElf_Ehdr *ehdr, Elf_Scn *scngrp)
          /* A section group refers to a non-existing section.  Should
             never happen.  */
          __libdw_free_zdata (result);
+         Dwarf_Sig8_Hash_free (&result->sig8_hash);
          __libdw_seterrno (DWARF_E_INVALID_ELF);
          free (result);
          return NULL;
@@ -471,11 +475,13 @@ dwarf_begin_elf (elf, cmd, scngrp)
     }
   else if (cmd == DWARF_C_WRITE)
     {
+      Dwarf_Sig8_Hash_free (&result->sig8_hash);
       __libdw_seterrno (DWARF_E_UNIMPL);
       free (result);
       return NULL;
     }
 
+  Dwarf_Sig8_Hash_free (&result->sig8_hash);
   __libdw_seterrno (DWARF_E_INVALID_CMD);
   free (result);
   return NULL;