In the unlikely case that __libdw_findcu fails to find the associated
CU we would leak one arange because it wasn't linked into the arangelist
list yet. Make sure to free it immediately.
Signed-off-by: Mark Wielaard <mark@klomp.org>
2018-06-05 Mark Wielaard <mark@klomp.org>
+ * dwarf_getaranges (dwarf_getaranges): Free new_arange if
+ __libdw_findcu fails.
+
+2018-06-05 Mark Wielaard <mark@klomp.org>
+
* dwarf_getsrclines.c (read_srclines): Define dirarray early and
check whether or not it is equal to dirstack on exit/out before
cleanup.
/* We store the actual CU DIE offset, not the CU header offset. */
Dwarf_CU *cu = __libdw_findcu (dbg, offset, false);
if (unlikely (cu == NULL))
- goto fail;
+ {
+ /* We haven't gotten a chance to link in the new_arange
+ into the arangelist, don't leak it. */
+ free (new_arange);
+ goto fail;
+ }
new_arange->arange.offset = __libdw_first_die_off_from_cu (cu);
new_arange->next = arangelist;