From 1202881f9add3577133575ed7deaa63336f42b97 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Thu, 13 Aug 2015 23:16:15 +0000 Subject: [PATCH] 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. llvm-svn: 244984 --- .../ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp index 8209d23c0aee..d9d399c5eff7 100644 --- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp +++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp @@ -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()); }