Don't call memmove when there's nothing to move. Fixes PR#27978.
llvm-svn: 271794
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: e499d086aa2b7a7248ded3f406ebf19ef53ad6c2
diff --git a/include/fstream b/include/fstream
index d51da45..3cb3b13 100644
--- a/include/fstream
+++ b/include/fstream
@@ -606,7 +606,9 @@
}
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),