[Lldb-commits] [PATCH] D59400: [lldb-vscode] Fix dangling pointer in request_evaluate.
Jorge Gorbe Moya via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Mar 14 18:05:41 PDT 2019
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59400.190764.patch
Type: text/x-patch
Size: 768 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190315/15ce3f6c/attachment.bin>
More information about the lldb-commits
mailing list