From f4d47d7140d7a738c0b793acf14c12ca53dc1c42 Mon Sep 17 00:00:00 2001 From: Johan 't Hart Date: Mon, 16 Jun 2014 11:38:16 +0200 Subject: [PATCH] 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. --- format.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/format.h b/format.h index c94aa8f0..761132ff 100644 --- a/format.h +++ b/format.h @@ -315,7 +315,7 @@ template void Array::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; }