From bf82b07f5f2ff1ebd3fb607a9f0d31d2b5ada947 Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Thu, 10 Jan 2013 00:07:38 +0000 Subject: [PATCH] [Object][Archive] Apparently StringRef::getAsInteger for APInt accepts spaces. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172022 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Object/Archive.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Object/Archive.cpp b/lib/Object/Archive.cpp index 95eba625edf..0d12be8f049 100644 --- a/lib/Object/Archive.cpp +++ b/lib/Object/Archive.cpp @@ -49,7 +49,7 @@ struct ArchiveMemberHeader { uint64_t getSize() const { uint64_t ret; - StringRef(Size, sizeof(Size)).getAsInteger(10, ret); + StringRef(Size, sizeof(Size)).rtrim(" ").getAsInteger(10, ret); return ret; } }; @@ -110,7 +110,7 @@ error_code Archive::Child::getName(StringRef &Result) const { } // It's a long name. // Get the offset. - uint64_t offset; + std::size_t offset; name.substr(1).getAsInteger(10, offset); const char *addr = Parent->StringTable->Data.begin() + sizeof(ArchiveMemberHeader) @@ -218,6 +218,10 @@ Archive::Archive(MemoryBuffer *source, error_code &ec) SymbolTable = i; StringTable = e; if (i != e) ++i; + if (i == e) { + ec = object_error::parse_failed; + return; + } if ((ec = i->getName(name))) return; if (name[0] != '/') {