<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 30, 2015 at 8:13 PM, Marshall Clow <span dir="ltr"><<a href="mailto:mclow.lists@gmail.com" target="_blank">mclow.lists@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: marshall<br>
Date: Sat May 30 22:13:31 2015<br>
New Revision: 238666<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D238666-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=rOSOTaiW_GkkSnf3NJH6-0boric0EHjC6O5heT1lPA0&s=gpkTkUUGkWEvTz17aR117wzehfAsyKg_P8yev8y8Wpk&e=" target="_blank">http://llvm.org/viewvc/llvm-project?rev=238666&view=rev</a><br>
Log:<br>
Don't try to memcpy zero bytes; sometimes the source pointer is NULL, and that's UB. Thanks to Nuno Lopes for the catch.<br>
<br>
Modified:<br>
libcxx/trunk/include/memory<br>
<br>
Modified: libcxx/trunk/include/memory<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_libcxx_trunk_include_memory-3Frev-3D238666-26r1-3D238665-26r2-3D238666-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=rOSOTaiW_GkkSnf3NJH6-0boric0EHjC6O5heT1lPA0&s=miub1OXOCoLHKherPiek3aw5AsX247VgcCKC2Bv2axo&e=" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=238666&r1=238665&r2=238666&view=diff</a><br>
==============================================================================<br>
--- libcxx/trunk/include/memory (original)<br>
+++ libcxx/trunk/include/memory Sat May 30 22:13:31 2015<br>
@@ -621,6 +621,8 @@ void* align(size_t alignment, size_t siz<br>
#pragma GCC system_header<br>
#endif<br>
<br>
+extern "C" int printf(const char * __restrict, ...);<br>
+<br></blockquote><div><br></div><div>Was this change intentional?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
_LIBCPP_BEGIN_NAMESPACE_STD<br>
<br>
// addressof moved to <__functional_base><br>
@@ -1521,7 +1523,8 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_t<br>
__construct_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)<br>
{<br>
ptrdiff_t _Np = __end1 - __begin1;<br>
- _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));<br>
+ if (_Np > 0)<br>
+ _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));<br>
__begin2 += _Np;<br>
}<br>
<br>
@@ -1549,7 +1552,8 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_t<br>
{<br>
typedef typename remove_const<_Tp>::type _Vp;<br>
ptrdiff_t _Np = __end1 - __begin1;<br>
- _VSTD::memcpy(const_cast<_Vp*>(__begin2), __begin1, _Np * sizeof(_Tp));<br>
+ if (_Np > 0)<br>
+ _VSTD::memcpy(const_cast<_Vp*>(__begin2), __begin1, _Np * sizeof(_Tp));<br>
__begin2 += _Np;<br>
}<br>
<br>
@@ -1580,7 +1584,8 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_t<br>
{<br>
ptrdiff_t _Np = __end1 - __begin1;<br>
__end2 -= _Np;<br>
- _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));<br>
+ if (_Np > 0)<br>
+ _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));<br>
}<br>
<br>
private:<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>