mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-10 01:55:08 +00:00
[lldb-vscode] Fix dangling pointer in request_evaluate.
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. Differential Revision: https://reviews.llvm.org/D59400 llvm-svn: 356227
This commit is contained in:
parent
e8710ef1fb
commit
717b1c804b
@ -965,7 +965,10 @@ void request_evaluate(const llvm::json::Object &request) {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user