From 1a844f54f79641e7d3e7754e875eaff0412dc765 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Sun, 6 Jan 2013 06:09:57 -0800 Subject: [PATCH] Issue #7: be more forgiving to incorrect DWARF that has extra NULLs in DIE trees --- elftools/dwarf/compileunit.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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() -- 2.30.2