diff options
author | Pavel Labath <pavel@labath.sk> | 2019-10-03 07:59:26 +0000 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2019-10-03 07:59:26 +0000 |
commit | ecd849ed5696fac0ac6a6eb8f7ec9d1034cb7a40 (patch) | |
tree | 2581482beb07c681368768e537403a6d0306b1c0 /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | |
parent | c0292744da798dc208727c0df7c31f90722d6752 (diff) | |
download | bcm5719-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.cpp | 3 |
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, ®_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; |