Fixed a crash in which we examined the extension of
authorSean Callanan <scallanan@apple.com>
Mon, 3 Dec 2012 21:28:37 +0000 (21:28 +0000)
committerSean Callanan <scallanan@apple.com>
Mon, 3 Dec 2012 21:28:37 +0000 (21:28 +0000)
a file name, whether the file name had an extension
or not.

<rdar://problem/12793152>

llvm-svn: 169156

lldb/source/Interpreter/ScriptInterpreterPython.cpp

index b23cda3..ac0baf4 100644 (file)
@@ -2493,10 +2493,13 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname,
         
         // strip .py or .pyc extension
         ConstString extension = target_file.GetFileNameExtension();
-        if (::strcmp(extension.GetCString(), "py") == 0)
-            basename.resize(basename.length()-3);
-        else if(::strcmp(extension.GetCString(), "pyc") == 0)
-            basename.resize(basename.length()-4);
+        if (extension)
+        {
+            if (::strcmp(extension.GetCString(), "py") == 0)
+                basename.resize(basename.length()-3);
+            else if(::strcmp(extension.GetCString(), "pyc") == 0)
+                basename.resize(basename.length()-4);
+        }
         
         // check if the module is already import-ed
         command_stream.Clear();