Skip to content

Commit

Permalink
When dwarf_srcfiles returns no entry, we cannot call dwarf_dealloc
Browse files Browse the repository at this point in the history
  • Loading branch information
mxz297 committed Dec 27, 2016
1 parent f4c4a71 commit 708699f
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions symtabAPI/src/dwarfWalker.C
Expand Up @@ -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;
}


Expand Down

0 comments on commit 708699f

Please sign in to comment.