Skip to content

Commit

Permalink
[Object] Don't crash on empty export lists.
Browse files Browse the repository at this point in the history
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224563 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
ributzka committed Dec 19, 2014
1 parent 94dfce4 commit 15067a6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/Object/MachOObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,10 @@ void ExportEntry::moveNext() {
iterator_range<export_iterator>
MachOObjectFile::exports(ArrayRef<uint8_t> Trie) {
ExportEntry Start(Trie);
Start.moveToFirst();
if (Trie.size() == 0)
Start.moveToEnd();
else
Start.moveToFirst();

ExportEntry Finish(Trie);
Finish.moveToEnd();
Expand Down
Binary file added test/Object/Inputs/macho-no-exports.dylib
Binary file not shown.
4 changes: 4 additions & 0 deletions test/Object/objdump-export-list.test
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 15067a6

Please sign in to comment.