Skip to content

Commit

Permalink
[Core] Fixed container pre-allocation in UTF8String.
Browse files Browse the repository at this point in the history
UTF8String::append() must reserve memory for current size plus new size, not just new size.
  • Loading branch information
LukasBanana committed Jun 23, 2024
1 parent 493bdea commit 352344f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sources/Core/UTF8String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<size_type>(dist));
data_.pop_back();
data_.reserve(static_cast<size_type>(dist) + 1);
data_.insert(data_.end(), first, last);
data_.push_back('\0');
}
Expand Down

0 comments on commit 352344f

Please sign in to comment.