summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2015-06-18 10:41:42 +0200
committerMark Wielaard <[email protected]>2015-06-19 12:23:55 +0200
commit65e58829fa0b6359735625e27309ae5eec7d810e (patch)
tree7a58c2240895158b6735915b99c672260546752e
parent1dcbe0c59a72eb1c6908ebce5209683769526349 (diff)
libdw: Not leak memory on error in dwarf_getpubnames.
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 <[email protected]>
-rw-r--r--libdw/ChangeLog4
-rw-r--r--libdw/dwarf_getpubnames.c1
2 files changed, 5 insertions, 0 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 577de920..8970ff6c 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,5 +1,9 @@
2015-06-18 Mark Wielaard <[email protected]>
+ * dwarf_getpubnames.c (get_offsets): Always free mem on error.
+
+2015-06-18 Mark Wielaard <[email protected]>
+
* dwarf_getmacros.c (get_macinfo_table): Return NULL when
dwarf_formudata reports an error.
(get_table_for_offset): Likewise.
diff --git a/libdw/dwarf_getpubnames.c b/libdw/dwarf_getpubnames.c
index 19f4eae1..41b2407b 100644
--- a/libdw/dwarf_getpubnames.c
+++ b/libdw/dwarf_getpubnames.c
@@ -127,6 +127,7 @@ get_offsets (Dwarf *dbg)
if (mem == NULL || cnt == 0)
{
+ free (mem);
__libdw_seterrno (DWARF_E_NO_ENTRY);
return -1;
}