Bring back null termination that slipped away

This commit is contained in:
Kein 2021-04-13 16:55:34 +03:00 committed by GitHub
parent f62dfa8f73
commit a88cabd417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -195,6 +195,7 @@ public class DiscordRpc
input.CopyTo(0, _chrBuffer, 0, len); input.CopyTo(0, _chrBuffer, 0, len);
var convbytecnt = Encoding.UTF8.GetBytes(_chrBuffer, 0, len, _byteBuffer, 0); var convbytecnt = Encoding.UTF8.GetBytes(_chrBuffer, 0, len, _byteBuffer, 0);
IntPtr buffer = Marshal.AllocHGlobal(convbytecnt + 1); IntPtr buffer = Marshal.AllocHGlobal(convbytecnt + 1);
Marshal.WriteByte(buffer, convbytecnt, 0);
_buffers.Add(buffer); _buffers.Add(buffer);
Marshal.Copy(_byteBuffer, 0, buffer, convbytecnt); Marshal.Copy(_byteBuffer, 0, buffer, convbytecnt);
return buffer; return buffer;