forked from OSchip/llvm-project
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
This commit is contained in:
parent
c0292744da
commit
ecd849ed56
|
@ -462,7 +462,8 @@ GetRegistersAsJSON(NativeThreadProtocol &thread) {
|
||||||
WriteRegisterValueInHexFixedWidth(stream, reg_ctx, *reg_info_p,
|
WriteRegisterValueInHexFixedWidth(stream, reg_ctx, *reg_info_p,
|
||||||
®_value, lldb::eByteOrderBig);
|
®_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;
|
return register_object;
|
||||||
|
|
Loading…
Reference in New Issue