jgorbe created this revision. jgorbe added reviewers: zturner, clayborg. Herald added a project: LLDB.
SBError::GetCString() returns a pointer to a string owned by the SBError object. The code here was calling GetCString on a temporary and using the returned pointer after the temporary was destroyed. Repository: rLLDB LLDB https://reviews.llvm.org/D59400 Files: lldb/tools/lldb-vscode/lldb-vscode.cpp Index: lldb/tools/lldb-vscode/lldb-vscode.cpp =================================================================== --- lldb/tools/lldb-vscode/lldb-vscode.cpp +++ lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -965,7 +965,10 @@ value = frame.EvaluateExpression(expression.data()); if (value.GetError().Fail()) { response["success"] = llvm::json::Value(false); - const char *error_cstr = value.GetError().GetCString(); + // This error object must live until we're done with the pointer returned + // by GetCString(). + lldb::SBError error = value.GetError(); + const char *error_cstr = error.GetCString(); if (error_cstr && error_cstr[0]) EmplaceSafeString(response, "message", std::string(error_cstr)); else
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp =================================================================== --- lldb/tools/lldb-vscode/lldb-vscode.cpp +++ lldb/tools/lldb-vscode/lldb-vscode.cpp @@ -965,7 +965,10 @@ value = frame.EvaluateExpression(expression.data()); if (value.GetError().Fail()) { response["success"] = llvm::json::Value(false); - const char *error_cstr = value.GetError().GetCString(); + // This error object must live until we're done with the pointer returned + // by GetCString(). + lldb::SBError error = value.GetError(); + const char *error_cstr = error.GetCString(); if (error_cstr && error_cstr[0]) EmplaceSafeString(response, "message", std::string(error_cstr)); else
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits