<div dir="ltr">The takeaway from this example is nothing we don't already know.  We need better test coverage.</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 31, 2017 at 8:08 AM Greg Clayton via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is one example of how StringRef causes issues because it was adopted everywhere. Is there any way we can change our functions so we can't run into this issue? Anything we can learn from this example?<br>
<br>
<br>
<br>
> On Oct 26, 2017, at 9:53 PM, Pavel Labath via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: labath<br>
> Date: Thu Oct 26 21:53:24 2017<br>
> New Revision: 316740<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=316740&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=316740&view=rev</a><br>
> Log:<br>
> Fix a use-after-free in lldb-server<br>
><br>
> UriParser::Parse is returning a StringRef pointing the the parsed<br>
> string, but we were calling it with a temporary string. Change this to a<br>
> local variable to make sure the string persists as long as we need it.<br>
><br>
> Modified:<br>
>    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp<br>
><br>
> Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp?rev=316740&r1=316739&r2=316740&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp?rev=316740&r1=316739&r2=316740&view=diff</a><br>
> ==============================================================================<br>
> --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp (original)<br>
> +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp Thu Oct 26 21:53:24 2017<br>
> @@ -128,8 +128,9 @@ Status GDBRemoteCommunicationServerPlatf<br>
>   llvm::StringRef platform_ip;<br>
>   int platform_port;<br>
>   llvm::StringRef platform_path;<br>
> -  bool ok = UriParser::Parse(GetConnection()->GetURI(), platform_scheme,<br>
> -                             platform_ip, platform_port, platform_path);<br>
> +  std::string platform_uri = GetConnection()->GetURI();<br>
> +  bool ok = UriParser::Parse(platform_uri, platform_scheme, platform_ip,<br>
> +                             platform_port, platform_path);<br>
>   UNUSED_IF_ASSERT_DISABLED(ok);<br>
>   assert(ok);<br>
><br>
><br>
><br>
> _______________________________________________<br>
> lldb-commits mailing list<br>
> <a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div>