Don't crash when we have a .a file that contains an object with a 16 character name. Any calls to std::string::erase must be bounds checked.

<rdar://problem/22260988>

llvm-svn: 244984
This commit is contained in:
Greg Clayton 2015-08-13 23:16:15 +00:00
parent aa0d51f062
commit 1202881f9a
1 changed files with 3 additions and 1 deletions

View File

@ -105,7 +105,9 @@ ObjectContainerBSDArchive::Object::Extract (const DataExtractor& data, lldb::off
{
// Strip off any spaces (if the object file name contains spaces it
// will use the extended format above).
str.erase (str.find(' '));
const size_t space_pos = str.find(' ');
if (space_pos != std::string::npos)
str.erase (space_pos);
ar_name.SetCString(str.c_str());
}