From 65e58829fa0b6359735625e27309ae5eec7d810e Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 18 Jun 2015 10:41:42 +0200 Subject: [PATCH] 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 --- libdw/ChangeLog | 4 ++++ libdw/dwarf_getpubnames.c | 1 + 2 files changed, 5 insertions(+) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 577de9202..8970ff6cd 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,7 @@ +2015-06-18 Mark Wielaard + + * dwarf_getpubnames.c (get_offsets): Always free mem on error. + 2015-06-18 Mark Wielaard * dwarf_getmacros.c (get_macinfo_table): Return NULL when diff --git a/libdw/dwarf_getpubnames.c b/libdw/dwarf_getpubnames.c index 19f4eae13..41b2407b1 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; } -- 2.47.3