aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/MachOObjectFile.cpp
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
commitfeef8c246966bcf8f3e21e74155812c98d48bda2 (patch)
tree36c00e091e9363d76bdb562cfecabc6132da1f2f /llvm/lib/Object/MachOObjectFile.cpp
parenta155ab2dd2290f3571853038c8495026160659cd (diff)
downloadllvm-feef8c246966bcf8f3e21e74155812c98d48bda2.zip
llvm-feef8c246966bcf8f3e21e74155812c98d48bda2.tar.gz
llvm-feef8c246966bcf8f3e21e74155812c98d48bda2.tar.bz2
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. llvm-svn: 179848
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r--llvm/lib/Object/MachOObjectFile.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index f5910dd..d26eb2c 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/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);
}
}