Added checks for null UTF8 inputs

This commit is contained in:
Ethan Lee 2020-05-28 10:39:25 -04:00
parent c782115e7f
commit 3e7eaf9d5b

View file

@ -68,7 +68,10 @@ namespace SDL2
{
if (str == null)
{
buffer[0] = 0;
if (bufferSize > 0)
{
buffer[0] = 0;
}
return buffer;
}
fixed (char* strPtr = str)
@ -94,7 +97,11 @@ namespace SDL2
}
internal static unsafe byte* Utf8EncodeNullable(string str)
{
int bufferSize = Utf8SizeNullable(str);
if (str == null)
{
return (byte*) 0;
}
int bufferSize = Utf8Size(str);
byte* buffer = (byte*) Marshal.AllocHGlobal(bufferSize);
fixed (char* strPtr = str)
{