[Object] Don't crash on empty export lists.

Summary: This fixes the exports iterator if the export list is empty.

Reviewers: Bigcheese, kledzik

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D6732

llvm-svn: 224563
This commit is contained in:
Juergen Ributzka 2014-12-19 02:31:01 +00:00
parent ce1d30142c
commit 4d7f70d47e
3 changed files with 8 additions and 1 deletions

View File

@ -1640,7 +1640,10 @@ void ExportEntry::moveNext() {
iterator_range<export_iterator> iterator_range<export_iterator>
MachOObjectFile::exports(ArrayRef<uint8_t> Trie) { MachOObjectFile::exports(ArrayRef<uint8_t> Trie) {
ExportEntry Start(Trie); ExportEntry Start(Trie);
Start.moveToFirst(); if (Trie.size() == 0)
Start.moveToEnd();
else
Start.moveToFirst();
ExportEntry Finish(Trie); ExportEntry Finish(Trie);
Finish.moveToEnd(); Finish.moveToEnd();

Binary file not shown.

View File

@ -0,0 +1,4 @@
RUN: llvm-objdump -exports-trie %p/Inputs/macho-no-exports.dylib | FileCheck %s
; Test that we don't crash with an empty export list.
CHECK: macho-no-exports.dylib: file format Mach-O 64-bit x86-64