mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-26 00:21:13 +00:00
Fix grow size during Array<>::append
When the resulting array must grow during append, one must make sure that the new elements _plus_ the current elements fit the new array size.
This commit is contained in:
parent
1aeac1b25a
commit
f4d47d7140
2
format.h
2
format.h
@ -315,7 +315,7 @@ template <typename T, std::size_t SIZE>
|
||||
void Array<T, SIZE>::append(const T *begin, const T *end) {
|
||||
std::ptrdiff_t num_elements = end - begin;
|
||||
if (size_ + num_elements > capacity_)
|
||||
Grow(num_elements);
|
||||
Grow(size_ + num_elements);
|
||||
std::copy(begin, end, CheckPtr(ptr_, capacity_) + size_);
|
||||
size_ += num_elements;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user