mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-25 04:56:13 +08:00
Off-by-one errors strike again. Thank goodness for ASAN and the bots.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345076 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -2606,8 +2606,13 @@ vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
|
|||||||
{
|
{
|
||||||
size_type __old_size = this->__size_;
|
size_type __old_size = this->__size_;
|
||||||
this->__size_ += __n;
|
this->__size_ += __n;
|
||||||
if (__old_size == 0 || (__old_size / __bits_per_word) != (this->__size_ / __bits_per_word))
|
if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word))
|
||||||
this->__begin_[this->__size_ / __bits_per_word] = __storage_type(0);
|
{
|
||||||
|
if (this->__size_ <= __bits_per_word)
|
||||||
|
this->__begin_[0] = __storage_type(0);
|
||||||
|
else
|
||||||
|
this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
|
||||||
|
}
|
||||||
_VSTD::fill_n(__make_iter(__old_size), __n, __x);
|
_VSTD::fill_n(__make_iter(__old_size), __n, __x);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2622,8 +2627,13 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI
|
|||||||
{
|
{
|
||||||
size_type __old_size = this->__size_;
|
size_type __old_size = this->__size_;
|
||||||
this->__size_ += _VSTD::distance(__first, __last);
|
this->__size_ += _VSTD::distance(__first, __last);
|
||||||
if (__old_size == 0 || (__old_size / __bits_per_word) != (this->__size_ / __bits_per_word))
|
if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word))
|
||||||
this->__begin_[this->__size_ / __bits_per_word] = __storage_type(0);
|
{
|
||||||
|
if (this->__size_ <= __bits_per_word)
|
||||||
|
this->__begin_[0] = __storage_type(0);
|
||||||
|
else
|
||||||
|
this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
|
||||||
|
}
|
||||||
_VSTD::copy(__first, __last, __make_iter(__old_size));
|
_VSTD::copy(__first, __last, __make_iter(__old_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user