]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Not leak memory on error in dwarf_getpubnames.
authorMark Wielaard <mjw@redhat.com>
Thu, 18 Jun 2015 08:41:42 +0000 (10:41 +0200)
committerMark Wielaard <mjw@redhat.com>
Fri, 19 Jun 2015 10:23:55 +0000 (12:23 +0200)
When there is an error with the first entry we might already have allocated
the memory but not yet set cnt to 1. Just always free the memory on error.
free (NULL) is a nop anyway and doesn't matter on a failure path.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdw/ChangeLog
libdw/dwarf_getpubnames.c

index 577de92029d5ff54c937b1dba9668011688a8dbb..8970ff6cd49f40a12274a7cea4ddd25c50f93429 100644 (file)
@@ -1,3 +1,7 @@
+2015-06-18  Mark Wielaard  <mjw@redhat.com>
+
+       * dwarf_getpubnames.c (get_offsets): Always free mem on error.
+
 2015-06-18  Mark Wielaard  <mjw@redhat.com>
 
        * dwarf_getmacros.c (get_macinfo_table): Return NULL when
index 19f4eae1313d4f388ec8ab523ae09b00c5dbca89..41b2407b1dcb5dadb461ecbce47571ad095dba3a 100644 (file)
@@ -127,6 +127,7 @@ get_offsets (Dwarf *dbg)
 
   if (mem == NULL || cnt == 0)
     {
+      free (mem);
       __libdw_seterrno (DWARF_E_NO_ENTRY);
       return -1;
     }