fix a crash on "lli ex" or any other file whose name is exactly two
authorChris Lattner <sabre@nondot.org>
Thu, 15 Apr 2010 03:32:19 +0000 (03:32 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 15 Apr 2010 03:32:19 +0000 (03:32 +0000)
characters long.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101336 91177308-0d34-0410-b5e6-96231b3b80d8

tools/lli/lli.cpp

index 81c17cd8fc16c568c0ff74943ef84d3ac389c7b3..affe6bb65314df01157e98fff4ee6b91e355e402 100644 (file)
@@ -192,7 +192,8 @@ int main(int argc, char **argv, char * const *envp) {
   } else {
     // Otherwise, if there is a .bc suffix on the executable strip it off, it
     // might confuse the program.
-    if (InputFile.rfind(".bc") == InputFile.length() - 3)
+    if (InputFile.size() > 3 && 
+        InputFile.rfind(".bc") == InputFile.length() - 3)
       InputFile.erase(InputFile.length() - 3);
   }