summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/fud_string.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/source/fud_string.cpp b/source/fud_string.cpp
index 58b6bd1..994689e 100644
--- a/source/fud_string.cpp
+++ b/source/fud_string.cpp
@@ -100,14 +100,14 @@ StringResult String::from(StringView view, Allocator* allocator)
String output{};
output.m_allocator = allocator;
- output.m_length = view.m_length;
- if (output.m_length >= output.m_capacity) {
- output.m_capacity = output.m_length + 1;
+ if (view.m_length >= output.capacity() + 1U) {
+ output.m_capacity = view.m_length + 1;
output.m_data = static_cast<utf8*>(M_TakeOrReturn(output.allocator()->allocate(output.m_capacity)));
fudAssert(output.m_data != nullptr);
}
+ output.setLength(view.m_length);
auto copyStatus = copyMem(output.dataMut(), output.m_capacity, view.m_data, output.m_length);
fudAssert(copyStatus == FudStatus::Success);