aboutsummaryrefslogtreecommitdiff
path: root/source/Plugins/Process
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-10-03 07:59:26 +0000
committerPavel Labath <pavel@labath.sk>2019-10-03 07:59:26 +0000
commit4d1c7a83b7a0797fcbbbca15a6fddb168e66e16d (patch)
treebb8947015349a16ebc73db53f21eed11834f3ee8 /source/Plugins/Process
parent4721f57de9edb8f1a6c9cdd879deb79e3b77e05b (diff)
downloadlldb-4d1c7a83b7a0797fcbbbca15a6fddb168e66e16d.tar.gz
Fix a use-after-free in GDBRemoteCommunicationServerLLGS
Although it's called "GetString", StreamString::GetString actually returns a StringRef. Creating a json object with a StringRef does not make a copy, which means the StringRef will be dangling as soon as the underlying stream is destroyed. Add a .str() to force the json object to hold a copy of the string. This fixes nearly every test on linux. git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@373572 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'source/Plugins/Process')
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 4e719143d..36fb17813 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -462,7 +462,8 @@ GetRegistersAsJSON(NativeThreadProtocol &thread) {
WriteRegisterValueInHexFixedWidth(stream, reg_ctx, *reg_info_p,
&reg_value, lldb::eByteOrderBig);
- register_object.try_emplace(llvm::to_string(reg_num), stream.GetString());
+ register_object.try_emplace(llvm::to_string(reg_num),
+ stream.GetString().str());
}
return register_object;