From 352344f025f85b6713b4ed36c35af2ee9c6b2924 Mon Sep 17 00:00:00 2001 From: Laura Hermanns Date: Sun, 23 Jun 2024 17:18:05 -0400 Subject: [PATCH] [Core] Fixed container pre-allocation in UTF8String. UTF8String::append() must reserve memory for current size plus new size, not just new size. --- sources/Core/UTF8String.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/Core/UTF8String.cpp b/sources/Core/UTF8String.cpp index 1e4040584d..ae26c77a0f 100644 --- a/sources/Core/UTF8String.cpp +++ b/sources/Core/UTF8String.cpp @@ -329,8 +329,8 @@ UTF8String& UTF8String::append(const char* first, const char* last) const difference_type dist = std::distance(first, last); if (dist > 0) { + data_.reserve(data_.size() + static_cast(dist)); data_.pop_back(); - data_.reserve(static_cast(dist) + 1); data_.insert(data_.end(), first, last); data_.push_back('\0'); }