From: gcmoreira Date: Thu, 2 Feb 2017 13:47:30 +0000 (+1100) Subject: Fix parsing string table (#134) X-Git-Tag: v0.25~49 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5533fd4c59c0e4560cbc979a7174e1f788d00ba9;p=pyelftools.git Fix parsing string table (#134) If for any reason parse_cstring_from_stream() cannot get a string in the given offset, it'll return None causing the following line raises an exception when it tries to get the decoded ascii string from the None object. --- diff --git a/elftools/elf/sections.py b/elftools/elf/sections.py index 99550ac..1bc1715 100644 --- a/elftools/elf/sections.py +++ b/elftools/elf/sections.py @@ -71,7 +71,7 @@ class StringTableSection(Section): """ table_offset = self['sh_offset'] s = parse_cstring_from_stream(self.stream, table_offset + offset) - return s.decode('ascii') + return s.decode('ascii') if s else '' class SymbolTableSection(Section):