diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-12 13:32:28 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-12 13:32:28 +0000 |
commit | 5e102c6c48f2cdfe1741f60805c830fb1e17fa47 (patch) | |
tree | 586f46dbe994c900e7e6cd49d302197a66198397 /lib | |
parent | 7ffc422659e29061511b9ae5f6fdda2458a76b50 (diff) | |
download | external_llvm-5e102c6c48f2cdfe1741f60805c830fb1e17fa47.zip external_llvm-5e102c6c48f2cdfe1741f60805c830fb1e17fa47.tar.gz external_llvm-5e102c6c48f2cdfe1741f60805c830fb1e17fa47.tar.bz2 |
Don't reject an empty archive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186159 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Object/Archive.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Object/Archive.cpp b/lib/Object/Archive.cpp index 60c6d21..7579a9a 100644 --- a/lib/Object/Archive.cpp +++ b/lib/Object/Archive.cpp @@ -212,9 +212,9 @@ error_code Archive::Child::getAsBinary(OwningPtr<Binary> &Result) const { Archive::Archive(MemoryBuffer *source, error_code &ec) : Binary(Binary::ID_Archive, source), SymbolTable(end_children()) { // Check for sufficient magic. - if (!source || source->getBufferSize() - < (8 + sizeof(ArchiveMemberHeader)) // Smallest archive. - || StringRef(source->getBufferStart(), 8) != Magic) { + assert(source); + if (source->getBufferSize() < 8 || + StringRef(source->getBufferStart(), 8) != Magic) { ec = object_error::invalid_file_type; return; } @@ -224,7 +224,7 @@ Archive::Archive(MemoryBuffer *source, error_code &ec) child_iterator e = end_children(); if (i == e) { - ec = object_error::parse_failed; + ec = object_error::success; return; } @@ -314,6 +314,8 @@ Archive::Archive(MemoryBuffer *source, error_code &ec) } Archive::child_iterator Archive::begin_children(bool skip_internal) const { + if (Data->getBufferSize() == 8) // empty archive. + return end_children(); const char *Loc = Data->getBufferStart() + strlen(Magic); Child c(this, Loc); // Skip internals at the beginning of an archive. |