From 708699f13c058fafb32fb5f78d0eabb9d9824a7a Mon Sep 17 00:00:00 2001 From: Xiaozhu Meng Date: Tue, 27 Dec 2016 14:38:55 -0600 Subject: [PATCH] When dwarf_srcfiles returns no entry, we cannot call dwarf_dealloc --- symtabAPI/src/dwarfWalker.C | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/symtabAPI/src/dwarfWalker.C b/symtabAPI/src/dwarfWalker.C index 950fa697d9..944a1c8b41 100644 --- a/symtabAPI/src/dwarfWalker.C +++ b/symtabAPI/src/dwarfWalker.C @@ -249,21 +249,28 @@ void DwarfParseActions::setModuleFromName(std::string moduleName) } bool DwarfWalker::buildSrcFiles(Dwarf_Debug dbg, Dwarf_Die entry, StringTablePtr srcFiles) { - Dwarf_Signed cnt = 0; + Dwarf_Signed cnt = 0; char** srcFileList; - Dwarf_Error error; - DWARF_ERROR_RET(dwarf_srcfiles(entry, &srcFileList, &cnt, &error)); + Dwarf_Error error; + int ret = dwarf_srcfiles(entry, &srcFileList, &cnt, &error); + DWARF_ERROR_RET(ret); + + if(!srcFiles->empty()) { + return true; + } // already parsed, the module had better be right. + srcFiles->push_back("Unknown file"); - if(!srcFiles->empty()) { + // The module does not have any source files.. + if (ret == DW_DLV_NO_ENTRY) { return true; - } // already parsed, the module had better be right. - srcFiles->push_back("Unknown file"); - for (unsigned i = 0; i < cnt; ++i) { - srcFiles->push_back(srcFileList[i]); - dwarf_dealloc(dbg, srcFileList[i], DW_DLA_STRING); - } + } + + for (unsigned i = 0; i < cnt; ++i) { + srcFiles->push_back(srcFileList[i]); + dwarf_dealloc(dbg, srcFileList[i], DW_DLA_STRING); + } dwarf_dealloc(dbg, srcFileList, DW_DLA_LIST); - return true; + return true; }