<div dir="ltr">Should probably pull this into the release as it fixes something that could miscompile in the future with a new host compiler.<br><br><div class="gmail_quote"><div dir="ltr">On Mon, Aug 3, 2015 at 5:56 PM Chandler Carruth <<a href="mailto:chandlerc@gmail.com">chandlerc@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: chandlerc<br>
Date: Mon Aug  3 19:53:01 2015<br>
New Revision: 243932<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D243932-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=8O9sJ56gcgDt_j-lyb_w4CeKAoJMDNFg8nJYjLhKjNo&s=fL4YZ1cglsfPfWJMwjhcA1Q4pzRrlijKg1vdsKulLkw&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=243932&view=rev</a><br>
Log:<br>
[UB] Fix another place where we would pass a null pointer to memcpy.<br>
<br>
This too was found by UBSan. Down to 35 failures for me.<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/ADT/StringMap.h<br>
<br>
Modified: llvm/trunk/include/llvm/ADT/StringMap.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_ADT_StringMap.h-3Frev-3D243932-26r1-3D243931-26r2-3D243932-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=8O9sJ56gcgDt_j-lyb_w4CeKAoJMDNFg8nJYjLhKjNo&s=MK_JUxn9FU1kqVMY7H114J_ly1sGP60ON2uvpsp0Poc&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=243932&r1=243931&r2=243932&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ADT/StringMap.h (original)<br>
+++ llvm/trunk/include/llvm/ADT/StringMap.h Mon Aug  3 19:53:01 2015<br>
@@ -158,7 +158,8 @@ public:<br>
<br>
     // Copy the string information.<br>
     char *StrBuffer = const_cast<char*>(NewItem->getKeyData());<br>
-    memcpy(StrBuffer, Key.data(), KeyLength);<br>
+    if (KeyLength > 0)<br>
+      memcpy(StrBuffer, Key.data(), KeyLength);<br>
     StrBuffer[KeyLength] = 0;  // Null terminate for convenience of clients.<br>
     return NewItem;<br>
   }<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" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>