addNamedStream takes ownership by making a copy, although I could perhaps make this more explicit by making the function accept a std::string<br><div class="gmail_quote"><div dir="ltr">On Fri, Mar 9, 2018 at 2:26 PM Reid Kleckner via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">rnk requested changes to this revision.<br>
rnk added inline comments.<br>
This revision now requires changes to proceed.<br>
<br>
<br>
================<br>
Comment at: lld/COFF/PDB.cpp:984<br>
+    std::string StreamName = (Twine("/src/files/") + File).str();<br>
+    ExitOnErr(Builder.addNamedStream(StreamName, NatvisData->getBuffer()));<br>
+  }<br>
----------------<br>
Hm, won't this make a UAF? The file is allocated here, we pass in a stringref, and nobody keeps the file mapping alive.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D44328" rel="noreferrer" target="_blank">https://reviews.llvm.org/D44328</a><br>
<br>
<br>
<br>
</blockquote></div>