From: Mark Wielaard Date: Fri, 8 Jun 2018 18:14:58 +0000 (+0200) Subject: libdw: dwarf_get_units should handle existing failure to open Dwarf. X-Git-Tag: elfutils-0.172~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b958e6b0fbe6aa246bbbbdec34487476b01d1f2e;p=thirdparty%2Felfutils.git libdw: dwarf_get_units should handle existing failure to open Dwarf. The other dwarf unit/cu iterators handle a NULL Dwarf handle as an existing error and return NULL. Don't crash. Signed-off-by: Mark Wielaard --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 23e11b9de..21cb03c24 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2018-06-08 Mark Wielaard + + * dwarf_get_units.c (dwarf_get_units): Handle existing error, no + dwarf. + 2018-06-08 Mark Wielaard * dwarf_getlocation.c (store_implicit_value): Return error when diff --git a/libdw/dwarf_get_units.c b/libdw/dwarf_get_units.c index aece17ef4..6215bf4bb 100644 --- a/libdw/dwarf_get_units.c +++ b/libdw/dwarf_get_units.c @@ -40,6 +40,10 @@ dwarf_get_units (Dwarf *dwarf, Dwarf_CU *cu, Dwarf_CU **next_cu, Dwarf_Half *version, uint8_t *unit_type, Dwarf_Die *cudie, Dwarf_Die *subdie) { + /* Handle existing error. */ + if (dwarf == NULL) + return -1; + Dwarf_Off off; bool v4type; if (cu == NULL)