Fixed serialization of null-strings

This commit is contained in:
Simon Lübeß
2023-12-25 18:58:06 +01:00
parent 20814a61b6
commit 7bd69c162f
2 changed files with 21 additions and 9 deletions
@@ -105,17 +105,22 @@ class SerializedObject
if (primitiveType == .String)
{
MonoString* string = (.)value;
char8* rawStringValue = Mono.mono_string_to_utf8(string);
// If the string is null, we store a nullptr and 0-length
StringView valueView = StringView(null, 0);
String stringValue = new String(rawStringValue);
if (value != null)
{
MonoString* string = (.)value;
char8* rawStringValue = Mono.mono_string_to_utf8(string);
_ownedString.Add(stringValue);
String stringValue = new String(rawStringValue);
Mono.mono_free(rawStringValue);
StringView valueView = stringValue;
_ownedString.Add(stringValue);
Mono.mono_free(rawStringValue);
valueView = stringValue;
}
Internal.MemCpy(&data, &valueView, sizeof(StringView));
}