diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-04-19 11:36:47 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-04-19 11:36:47 +0000 |
commit | db5f9270207292b62ea847560c5dd4e9873b57f5 (patch) | |
tree | ee98d522b356532d15125ea1169791324a9c27a6 /tools/llvm-objdump | |
parent | 4521019c6fd23680c583abe086067fc1c569bad1 (diff) |
Don't read one command past the end.
Thanks to Evgeniy Stepanov for reporting this.
It might be a good idea to add a command iterator abstraction to MachO.h, but
this fixes the bug for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179848 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-objdump')
-rw-r--r-- | tools/llvm-objdump/MachODump.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp index e4d9ce2498..d78d7f31a6 100644 --- a/tools/llvm-objdump/MachODump.cpp +++ b/tools/llvm-objdump/MachODump.cpp @@ -205,7 +205,7 @@ getSectionsAndSymbols(const macho::Header Header, MachOObjectFile::LoadCommandInfo Command = MachOObj->getFirstLoadCommandInfo(); - for (unsigned i = 0; i != Header.NumLoadCommands; ++i) { + for (unsigned i = 0; ; ++i) { if (Command.C.Type == macho::LCT_FunctionStarts) { // We found a function starts segment, parse the addresses for later // consumption. @@ -214,7 +214,11 @@ getSectionsAndSymbols(const macho::Header Header, MachOObj->ReadULEB128s(LLC.DataOffset, FoundFns); } - Command = MachOObj->getNextLoadCommandInfo(Command); + + if (i == Header.NumLoadCommands - 1) + break; + else + Command = MachOObj->getNextLoadCommandInfo(Command); } } |