Author: marshall
Date: Sat Jun  4 11:16:59 2016
New Revision: 271794

URL: http://llvm.org/viewvc/llvm-project?rev=271794&view=rev
Log:
Don't call memmove when there's nothing to move. Fixes PR#27978.

Modified:
    libcxx/trunk/include/fstream

Modified: libcxx/trunk/include/fstream
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/fstream?rev=271794&r1=271793&r2=271794&view=diff
==============================================================================
--- libcxx/trunk/include/fstream (original)
+++ libcxx/trunk/include/fstream Sat Jun  4 11:16:59 2016
@@ -606,7 +606,9 @@ basic_filebuf<_CharT, _Traits>::underflo
         }
         else
         {
-            memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
+            _LIBCPP_ASSERT ( !(__extbufnext_ == NULL && (__extbufend_ != 
__extbufnext_)), "underflow moving from NULL" );
+            if (__extbufend_ != __extbufnext_)
+                memmove(__extbuf_, __extbufnext_, __extbufend_ - 
__extbufnext_);
             __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
             __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? 
sizeof(__extbuf_min_) : __ebs_);
             size_t __nmemb = _VSTD::min(static_cast<size_t>(__ibs_ - 
__unget_sz),


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to