Issue #7: be more forgiving to incorrect DWARF that has extra NULLs in DIE trees
authorEli Bendersky <eliben@gmail.com>
Sun, 6 Jan 2013 14:09:57 +0000 (06:09 -0800)
committerEli Bendersky <eliben@gmail.com>
Sun, 6 Jan 2013 14:09:57 +0000 (06:09 -0800)
elftools/dwarf/compileunit.py

index fbe4a8b302282373cfeeee3024b44543eaf794c5..f7acaab89b2362c53dbf40fa4f280d80aeb15d2e 100644 (file)
@@ -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()