<div dir="ltr"><div class="gmail_extra"><div>On Thu, Sep 26, 2013 at 4:08 PM, Sean Silva <span dir="ltr"><<a href="mailto:silvas@purdue.edu" target="_blank">silvas@purdue.edu</a>></span> wrote:<br></div><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">asan?</div></blockquote><div><br></div><div>
Nope, just Windows debug allocator clearing memory on free.</div><div><br></div><div>- Michael Spencer<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Sep 25, 2013 at 6:12 PM, Michael J. Spencer <span dir="ltr"><<a href="mailto:bigcheesegs@gmail.com" target="_blank">bigcheesegs@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: mspencer<br>
Date: Wed Sep 25 17:12:14 2013<br>
New Revision: 191403<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=191403&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=191403&view=rev</a><br>
Log:<br>
[ELF] Fix use after free.<br>
<br>
Modified:<br>
    lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h<br>
    lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp<br>
<br>
Modified: lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=191403&r1=191402&r2=191403&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=191403&r1=191402&r2=191403&view=diff</a><br>


==============================================================================<br>
--- lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h (original)<br>
+++ lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h Wed Sep 25 17:12:14 2013<br>
@@ -156,7 +156,7 @@ public:<br>
   virtual void setNoAllowDynamicLibraries() { _noAllowDynamicLibraries = true; }<br>
<br>
   /// Searches directories for a match on the input File<br>
-  llvm::ErrorOr<std::string><br>
+  llvm::ErrorOr<StringRef><br>
   searchLibrary(StringRef libName,<br>
                 const std::vector<StringRef> &searchPath) const;<br>
<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=191403&r1=191402&r2=191403&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=191403&r1=191402&r2=191403&view=diff</a><br>


==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp Wed Sep 25 17:12:14 2013<br>
@@ -149,48 +149,49 @@ ELFLinkingContext::create(llvm::Triple t<br>
   }<br>
 }<br>
<br>
-llvm::ErrorOr<std::string> ELFLinkingContext::searchLibrary(<br>
+llvm::ErrorOr<StringRef> ELFLinkingContext::searchLibrary(<br>
     StringRef libName, const std::vector<StringRef> &searchPath) const {<br>
   bool foundFile = false;<br>
   StringRef pathref;<br>
+  SmallString<128> path;<br>
   for (StringRef dir : searchPath) {<br>
     // Search for dynamic library<br>
     if (!_isStaticExecutable) {<br>
-      SmallString<128> dynlibPath;<br>
+      path.clear();<br>
       if (dir.startswith("=/")) {<br>
-        dynlibPath.assign(_sysrootPath);<br>
-        dynlibPath.append(dir.substr(1));<br>
+        path.assign(_sysrootPath);<br>
+        path.append(dir.substr(1));<br>
       } else {<br>
-        dynlibPath.assign(dir);<br>
+        path.assign(dir);<br>
       }<br>
-      llvm::sys::path::append(dynlibPath, Twine("lib") + libName + ".so");<br>
-      pathref = dynlibPath.str();<br>
+      llvm::sys::path::append(path, Twine("lib") + libName + ".so");<br>
+      pathref = path.str();<br>
       if (llvm::sys::fs::exists(pathref)) {<br>
         foundFile = true;<br>
       }<br>
     }<br>
     // Search for static libraries too<br>
     if (!foundFile) {<br>
-      SmallString<128> archivefullPath;<br>
+      path.clear();<br>
       if (dir.startswith("=/")) {<br>
-        archivefullPath.assign(_sysrootPath);<br>
-        archivefullPath.append(dir.substr(1));<br>
+        path.assign(_sysrootPath);<br>
+        path.append(dir.substr(1));<br>
       } else {<br>
-        archivefullPath.assign(dir);<br>
+        path.assign(dir);<br>
       }<br>
-      llvm::sys::path::append(archivefullPath, Twine("lib") + libName + ".a");<br>
-      pathref = archivefullPath.str();<br>
+      llvm::sys::path::append(path, Twine("lib") + libName + ".a");<br>
+      pathref = path.str();<br>
       if (llvm::sys::fs::exists(pathref)) {<br>
         foundFile = true;<br>
       }<br>
     }<br>
     if (foundFile)<br>
-      return (*(new (_alloc) std::string(pathref.str())));<br>
+      return StringRef(*new (_alloc) std::string(pathref));<br>
   }<br>
   if (!llvm::sys::fs::exists(libName))<br>
     return llvm::make_error_code(llvm::errc::no_such_file_or_directory);<br>
<br>
-  return std::string(libName);<br>
+  return libName;<br>
 }<br>
<br>
 std::unique_ptr<File> ELFLinkingContext::createUndefinedSymbolFile() {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>