summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/MachOObjectFile.cpp
diff options
context:
space:
mode:
authorFilipe Cabecinhas <me@filcab.net>2015-01-06 17:08:26 +0000
committerFilipe Cabecinhas <me@filcab.net>2015-01-06 17:08:26 +0000
commite71bd0c89bfe64fefb703c16397ad0e5debc7802 (patch)
tree61e99b6849eb58765286b6eb6c223e8a946bda1c /llvm/lib/Object/MachOObjectFile.cpp
parent243a5481d9221bf8733fef538a600bcc6117933e (diff)
downloadbcm5719-llvm-e71bd0c89bfe64fefb703c16397ad0e5debc7802.tar.gz
bcm5719-llvm-e71bd0c89bfe64fefb703c16397ad0e5debc7802.zip
Don't loop endlessly for MachO files with 0 ncmds
llvm-svn: 225271
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r--llvm/lib/Object/MachOObjectFile.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index 1373dbab410..e4769762be4 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -236,6 +236,9 @@ MachOObjectFile::MachOObjectFile(MemoryBufferRef Object, bool IsLittleEndian,
DataInCodeLoadCmd(nullptr), DyldInfoLoadCmd(nullptr),
UuidLoadCmd(nullptr), HasPageZeroSegment(false) {
uint32_t LoadCommandCount = this->getHeader().ncmds;
+ if (LoadCommandCount == 0)
+ return;
+
MachO::LoadCommandType SegmentLoadType = is64Bit() ?
MachO::LC_SEGMENT_64 : MachO::LC_SEGMENT;
OpenPOWER on IntegriCloud