From: David Majnemer Date: Sun, 29 May 2016 06:18:08 +0000 (+0000) Subject: Don't dereference a symbol iterator before checking for the end case X-Git-Tag: android-x86-7.1-r4~32579 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=02cabd40cd77aaba94a12b9e9eec6327ea85e748;p=android-x86%2Fexternal-llvm.git 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 --- diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp index 029674b8d63..bf6a7b4a2b0 100644 --- a/tools/llvm-readobj/COFFDumper.cpp +++ b/tools/llvm-readobj/COFFDumper.cpp @@ -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