summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
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
commitecd849ed5696fac0ac6a6eb8f7ec9d1034cb7a40 (patch)
tree2581482beb07c681368768e537403a6d0306b1c0 /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
parentc0292744da798dc208727c0df7c31f90722d6752 (diff)
downloadbcm5719-llvm-ecd849ed5696fac0ac6a6eb8f7ec9d1034cb7a40.tar.gz
bcm5719-llvm-ecd849ed5696fac0ac6a6eb8f7ec9d1034cb7a40.zip
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. llvm-svn: 373572
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 4e719143da5..36fb1781364 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/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;
OpenPOWER on IntegriCloud