From: Mark Wielaard Date: Tue, 18 Dec 2012 13:14:22 +0000 (+0100) Subject: Fix sig8_hash memory leak in libdw/dwarf_begin_elf.c on error. X-Git-Tag: elfutils-0.156~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59254427e7c9eeb697de00069a9cb7dc1c908f86;p=thirdparty%2Felfutils.git Fix sig8_hash memory leak in libdw/dwarf_begin_elf.c on error. Signed-off-by: Mark Wielaard --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 0d35ca91a..24f4bb488 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,10 @@ +2012-12-18 Mark Wielaard + + * 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 * dwarf_getlocation.c (__libdw_intern_expression): Handle diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c index a9c826ced..6cf3aa178 100644 --- a/libdw/dwarf_begin_elf.c +++ b/libdw/dwarf_begin_elf.c @@ -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;