summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-04-19 11:36:47 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-04-19 11:36:47 +0000
commitdb5f9270207292b62ea847560c5dd4e9873b57f5 (patch)
treeee98d522b356532d15125ea1169791324a9c27a6 /lib
parent4521019c6fd23680c583abe086067fc1c569bad1 (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 'lib')
-rw-r--r--lib/Object/MachOObjectFile.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp
index f5910dd95d7..d26eb2ce611 100644
--- a/lib/Object/MachOObjectFile.cpp
+++ b/lib/Object/MachOObjectFile.cpp
@@ -405,7 +405,7 @@ MachOObjectFile::MachOObjectFile(MemoryBuffer *Object,
macho::LCT_Segment64 : macho::LCT_Segment;
MachOObjectFile::LoadCommandInfo Load = getFirstLoadCommandInfo();
- for (unsigned I = 0; I < LoadCommandCount; ++I) {
+ for (unsigned I = 0; ; ++I) {
if (Load.C.Type == macho::LCT_Symtab) {
assert(!SymtabLoadCmd && "Multiple symbol tables");
SymtabLoadCmd = Load.Ptr;
@@ -418,7 +418,11 @@ MachOObjectFile::MachOObjectFile(MemoryBuffer *Object,
Sections.push_back(reinterpret_cast<const char*>(Sec));
}
}
- Load = getNextLoadCommandInfo(Load);
+
+ if (I == LoadCommandCount - 1)
+ break;
+ else
+ Load = getNextLoadCommandInfo(Load);
}
}