From ae7dd12a301dc7acf2bf713e81154954b3f16372 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 27 Oct 2017 04:53:24 +0000 Subject: [PATCH] Fix a use-after-free in lldb-server UriParser::Parse is returning a StringRef pointing the the parsed string, but we were calling it with a temporary string. Change this to a local variable to make sure the string persists as long as we need it. llvm-svn: 316740 --- .../gdb-remote/GDBRemoteCommunicationServerPlatform.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp index 977c34c2a69b..04ed9d704e13 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -128,8 +128,9 @@ Status GDBRemoteCommunicationServerPlatform::LaunchGDBServer( llvm::StringRef platform_ip; int platform_port; llvm::StringRef platform_path; - bool ok = UriParser::Parse(GetConnection()->GetURI(), platform_scheme, - platform_ip, platform_port, platform_path); + std::string platform_uri = GetConnection()->GetURI(); + bool ok = UriParser::Parse(platform_uri, platform_scheme, platform_ip, + platform_port, platform_path); UNUSED_IF_ASSERT_DISABLED(ok); assert(ok);