diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2016-06-04 16:16:59 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2016-06-04 16:16:59 +0000 |
commit | 27006195205f3f3e9d389a46bc29e80458621194 (patch) | |
tree | b4affead658700036512beff727b9b6370a989fe /include/fstream | |
parent | 1575e3e813f7f7cde31e699802fa1fcf8e84531c (diff) |
Don't call memmove when there's nothing to move. Fixes PR#27978.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271794 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/fstream')
-rw-r--r-- | include/fstream | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/include/fstream b/include/fstream index d51da45d8..3cb3b13bd 100644 --- a/include/fstream +++ b/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), |