summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2016-06-04 16:16:59 +0000
committerMarshall Clow <mclow.lists@gmail.com>2016-06-04 16:16:59 +0000
commite499d086aa2b7a7248ded3f406ebf19ef53ad6c2 (patch)
tree0c5c03f667dcd8e2b077977cc145ec6ec4b3d868
parent8c46a4ceea5254c2d5716d1c3ed7a309697d9f96 (diff)
downloadbcm5719-llvm-e499d086aa2b7a7248ded3f406ebf19ef53ad6c2.tar.gz
bcm5719-llvm-e499d086aa2b7a7248ded3f406ebf19ef53ad6c2.zip
Don't call memmove when there's nothing to move. Fixes PR#27978.
llvm-svn: 271794
-rw-r--r--libcxx/include/fstream4
1 files changed, 3 insertions, 1 deletions
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index d51da45d874..3cb3b13bd10 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -606,7 +606,9 @@ basic_filebuf<_CharT, _Traits>::underflow()
}
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),
OpenPOWER on IntegriCloud