Don't dereference a symbol iterator before checking for the end case

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271173 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer 2016-05-29 06:18:08 +00:00
parent b829a5d681
commit 02cabd40cd

View File

@ -208,15 +208,19 @@ std::error_code COFFDumper::resolveSymbol(const coff_section *Section,
uint64_t Offset, SymbolRef &Sym) {
cacheRelocations();
const auto &Relocations = RelocMap[Section];
auto SymI = Obj->symbol_end();
for (const auto &Relocation : Relocations) {
uint64_t RelocationOffset = Relocation.getOffset();
if (RelocationOffset == Offset) {
Sym = *Relocation.getSymbol();
return readobj_error::success;
SymI = Relocation.getSymbol();
break;
}
}
return readobj_error::unknown_symbol;
if (SymI == Obj->symbol_end())
return readobj_error::unknown_symbol;
Sym = *SymI;
return readobj_error::success;
}
// Given a section and an offset into this section the function returns the name