This is an archive of the discontinued LLVM Phabricator instance.

[lldb-vscode] Fix dangling pointer in request_evaluate.
ClosedPublic

Authored by jgorbe on Mar 14 2019, 6:05 PM.

Details

Summary

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.

Diff Detail

Repository
rLLDB LLDB

Event Timeline

jgorbe created this revision.Mar 14 2019, 6:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2019, 6:05 PM

Another option would be to just assign it to a std::string, but this is fine too.

zturner accepted this revision.Mar 14 2019, 6:28 PM
This revision is now accepted and ready to land.Mar 14 2019, 6:28 PM

I considered assigning it to a std::string, but GetCString() can return a null pointer and I'm not sure you can construct a std::string directly from that.

This revision was automatically updated to reflect the committed changes.