Added checks for null UTF8 inputs
This commit is contained in:
parent
c782115e7f
commit
3e7eaf9d5b
11
src/SDL2.cs
11
src/SDL2.cs
@ -68,7 +68,10 @@ namespace SDL2
|
|||||||
{
|
{
|
||||||
if (str == null)
|
if (str == null)
|
||||||
{
|
{
|
||||||
buffer[0] = 0;
|
if (bufferSize > 0)
|
||||||
|
{
|
||||||
|
buffer[0] = 0;
|
||||||
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
fixed (char* strPtr = str)
|
fixed (char* strPtr = str)
|
||||||
@ -94,7 +97,11 @@ namespace SDL2
|
|||||||
}
|
}
|
||||||
internal static unsafe byte* Utf8EncodeNullable(string str)
|
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);
|
byte* buffer = (byte*) Marshal.AllocHGlobal(bufferSize);
|
||||||
fixed (char* strPtr = str)
|
fixed (char* strPtr = str)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user