[Lldb-commits] [lldb] r353581 - Tiny fix spotted by static analyzer; GetPath() returns a std::string,

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 8 15:36:25 PST 2019


Author: jmolenda
Date: Fri Feb  8 15:36:25 2019
New Revision: 353581

URL: http://llvm.org/viewvc/llvm-project?rev=353581&view=rev
Log:
Tiny fix spotted by static analyzer; GetPath() returns a std::string,
we get a pointer to the c-string rep and then the temporary object
is destructed and we still refer to the c-string after that.


Modified:
    lldb/trunk/source/Target/Platform.cpp

Modified: lldb/trunk/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=353581&r1=353580&r2=353581&view=diff
==============================================================================
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Fri Feb  8 15:36:25 2019
@@ -1059,11 +1059,11 @@ Status Platform::LaunchProcess(ProcessLa
       uint32_t num_resumes = GetResumeCountForLaunchInfo(launch_info);
       if (log) {
         const FileSpec &shell = launch_info.GetShell();
-        const char *shell_str = (shell) ? shell.GetPath().c_str() : "<null>";
+        std::string shell_str = (shell) ? shell.GetPath() : "<null>";
         log->Printf(
             "Platform::%s GetResumeCountForLaunchInfo() returned %" PRIu32
             ", shell is '%s'",
-            __FUNCTION__, num_resumes, shell_str);
+            __FUNCTION__, num_resumes, shell_str.c_str());
       }
 
       if (!launch_info.ConvertArgumentsForLaunchingInShell(




More information about the lldb-commits mailing list