From: Eli Bendersky Date: Sun, 6 Jan 2013 14:09:57 +0000 (-0800) Subject: Issue #7: be more forgiving to incorrect DWARF that has extra NULLs in DIE trees X-Git-Tag: v0.21~34 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1a844f54f79641e7d3e7754e875eaff0412dc765;p=pyelftools.git Issue #7: be more forgiving to incorrect DWARF that has extra NULLs in DIE trees --- diff --git a/elftools/dwarf/compileunit.py b/elftools/dwarf/compileunit.py index fbe4a8b..f7acaab 100644 --- a/elftools/dwarf/compileunit.py +++ b/elftools/dwarf/compileunit.py @@ -143,6 +143,11 @@ class CompileUnit(object): if die.has_children: parentstack.append(die) else: - # end of children for the current parent - parentstack.pop() + # parentstack should not be really empty here. However, some + # compilers generate DWARF that has extra NULLs in the end and + # we don't want pyelftools to fail parsing them just because of + # this. + if len(parentstack) > 0: + # end of children for the current parent + parentstack.pop()