From 3a9a6a34bb0aa305a643ee7b3c30ac829d86f2ff Mon Sep 17 00:00:00 2001 From: kayomn Date: Sun, 19 Feb 2023 16:31:45 +0000 Subject: [PATCH] Fix runtime error regression in core::copy --- source/core/sequence.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/core/sequence.cpp b/source/core/sequence.cpp index 7e59719..316427b 100644 --- a/source/core/sequence.cpp +++ b/source/core/sequence.cpp @@ -70,8 +70,7 @@ export namespace core { usize const updated_fill = this->filled + source_elements.length; if (updated_fill >= this->elements.length) { - append_result const result = - this->reserve(max(this->elements.length, updated_fill)); + append_result const result = this->reserve(updated_fill); if (result != append_result::ok) return result; } @@ -155,7 +154,7 @@ export namespace core { * `initial_capacity` argument. */ append_result reserve(usize capacity) { - usize const requested_capacity = this->elements.length + capacity; + usize const requested_capacity = this->filled + capacity; if (this->is_dynamic()) { // Grow dynamic buffer (bailing out if failed).