libluna: Fix String::from_string_view construction for inline strings
All checks were successful
Build and test / build (push) Successful in 1m41s

Before, this method failed to add a null terminator if the source string did not have one, which was possible.
This commit is contained in:
apio 2024-02-11 17:09:37 +01:00
parent 644614cdd8
commit 4dc060e0b3
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -155,7 +155,8 @@ Result<String> String::from_string_view(StringView str)
String result;
result.m_inline = true;
result.m_length = str.length();
strncpy(result.m_inline_storage, str.chars(), sizeof(m_inline_storage));
memset(result.m_inline_storage, 0, sizeof(result.m_inline_storage));
memcpy(result.m_inline_storage, str.chars(), str.length());
return result;
}