From c787ad8f8d87133fab8201f1452ee24817fe7d0a Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Wed, 29 May 2019 16:54:26 -0400 Subject: [PATCH] Return an empty string on, er, empty string --- src/SDL2.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/SDL2.cs b/src/SDL2.cs index b617abb..090a795 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -91,6 +91,10 @@ namespace SDL2 #else /* Old C# requires an extra memcpy, bleh! */ int len = (int) (ptr - (byte*) s); + if (len == 0) + { + return string.Empty; + } char* chars = stackalloc char[len]; int strLen = System.Text.Encoding.UTF8.GetChars((byte*) s, len, chars, len); string result = new string(chars, 0, strLen);