]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: dwarf_get_units should handle existing failure to open Dwarf.
authorMark Wielaard <mark@klomp.org>
Fri, 8 Jun 2018 18:14:58 +0000 (20:14 +0200)
committerMark Wielaard <mark@klomp.org>
Mon, 11 Jun 2018 06:35:51 +0000 (08:35 +0200)
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 <mark@klomp.org>
libdw/ChangeLog
libdw/dwarf_get_units.c

index 23e11b9dee2cd479527c07b2ceddcff599c4225d..21cb03c24b40b1e90597d3efb95068bf83a68b9a 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-08  Mark Wielaard  <mark@klomp.org>
+
+       * dwarf_get_units.c (dwarf_get_units): Handle existing error, no
+       dwarf.
+
 2018-06-08  Mark Wielaard  <mark@klomp.org>
 
        * dwarf_getlocation.c (store_implicit_value): Return error when
index aece17ef4cd62d3fed8c732869c6f18586c8418c..6215bf4bb4ebd647b93540a6fee9e4bc9357a198 100644 (file)
@@ -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)