From 2512479689886bc6ea733f84a1b3df96fe13d3d9 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 25 Nov 2017 16:37:18 +1100 Subject: [PATCH] Fix issues with NULL char not being treated properly (Thanks tornato) --- MCGalaxy/Network/Utils/NetUtils.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MCGalaxy/Network/Utils/NetUtils.cs b/MCGalaxy/Network/Utils/NetUtils.cs index 39db5a171..db2fe7183 100644 --- a/MCGalaxy/Network/Utils/NetUtils.cs +++ b/MCGalaxy/Network/Utils/NetUtils.cs @@ -72,8 +72,9 @@ namespace MCGalaxy { char* characters = stackalloc char[StringSize]; for (int i = StringSize - 1; i >= 0; i--) { byte code = data[i + offset]; - if( length == 0 && !(code == 0x00 || code == 0x20)) - length = i + 1; + if (code == 0) code = 0x20; // NULL to space + + if (length == 0 && code != 0x20) { length = i + 1; } characters[i] = ((char)code).Cp437ToUnicode(); } return new String(characters, 0, length);