libdw: Fix crashing on illegal/zero Dwarf_Die.
authorMark Wielaard <mark@klomp.org>
Wed, 9 May 2018 21:27:12 +0000 (23:27 +0200)
committerMark Wielaard <mark@klomp.org>
Tue, 15 May 2018 09:25:03 +0000 (11:25 +0200)
commitb9c76ded0f07d270bbb9314fb970bb0afcb71d58
tree94c3f714cb6173080056f9357e40ce208b11309d
parent9dd183f3d036221758b5a53a8918fd7c568282cb
libdw: Fix crashing on illegal/zero Dwarf_Die.

In some cases we create an illegal Dwarf_Die by clearing all fields.
The idea is that dwarf_tag () on such a Dwarf_Die will return
DW_TAG_invalid, to indicate that the Dwarf_Die is unusable (and other
functions will also return errors).  But when "reconstructing" the
Dwarf_Die addr we might use the cu before realizing the Dwarf_Die is
invalid.  Fix this with an explicit NULL check and add a testcase.

Signed-off-by: Mark Wielaard <mark@klomp.org>
libdw/ChangeLog
libdw/dwarf_siblingof.c
libdw/libdwP.h
tests/ChangeLog
tests/Makefile.am
tests/get-units-invalid.c [new file with mode: 0644]
tests/run-get-units-invalid.sh [new file with mode: 0755]