From dd6f7face81c94eb0836f55386123742c264653c Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Wed, 27 Jun 2018 15:43:10 -0400 Subject: [PATCH] Use GetChars return value --- src/SDL2.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SDL2.cs b/src/SDL2.cs index faf01bf..8625567 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -91,8 +91,8 @@ namespace SDL2 /* Old C# requires an extra memcpy, bleh! */ int len = (int) (ptr - (byte*) s); char* chars = stackalloc char[len]; - System.Text.Encoding.UTF8.GetChars((byte*) s, len, chars, len); - string result = new string(chars); + int strLen = System.Text.Encoding.UTF8.GetChars((byte*) s, len, chars, len); + string result = new string(chars, 0, strLen); #endif /* Some SDL functions will malloc, we have to free! */