diff --git a/src/ImGui.NET/ImGui.Manual.ReadOnlySpan.cs b/src/ImGui.NET/ImGui.Manual.ReadOnlySpan.cs index 8fe914f2..aaed366e 100644 --- a/src/ImGui.NET/ImGui.Manual.ReadOnlySpan.cs +++ b/src/ImGui.NET/ImGui.Manual.ReadOnlySpan.cs @@ -58,6 +58,7 @@ public static bool InputText( utf8LabelBytes = stackPtr; } Util.GetUtf8(label, utf8LabelBytes, utf8LabelByteCount); + utf8LabelBytes[utf8LabelByteCount] = 0; bool ret; fixed (byte* bufPtr = buf) @@ -111,6 +112,7 @@ public static bool InputText( utf8LabelBytes = stackPtr; } Util.GetUtf8(label, utf8LabelBytes, utf8LabelByteCount); + utf8LabelBytes[utf8LabelByteCount] = 0; int utf8InputByteCount = Encoding.UTF8.GetByteCount(input); int inputBufSize = Math.Max((int)maxLength + 1, utf8InputByteCount + 1); @@ -201,6 +203,7 @@ public static bool InputTextMultiline( utf8LabelBytes = stackPtr; } Util.GetUtf8(label, utf8LabelBytes, utf8LabelByteCount); + utf8LabelBytes[utf8LabelByteCount] = 0; int utf8InputByteCount = Encoding.UTF8.GetByteCount(input); int inputBufSize = Math.Max((int)maxLength + 1, utf8InputByteCount + 1); @@ -292,6 +295,7 @@ public static bool InputTextWithHint( utf8LabelBytes = stackPtr; } Util.GetUtf8(label, utf8LabelBytes, utf8LabelByteCount); + utf8LabelBytes[utf8LabelByteCount] = 0; int utf8HintByteCount = Encoding.UTF8.GetByteCount(hint); byte* utf8HintBytes; @@ -305,6 +309,7 @@ public static bool InputTextWithHint( utf8HintBytes = stackPtr; } Util.GetUtf8(hint, utf8HintBytes, utf8HintByteCount); + utf8HintBytes[utf8HintByteCount] = 0; int utf8InputByteCount = Encoding.UTF8.GetByteCount(input); int inputBufSize = Math.Max((int)maxLength + 1, utf8InputByteCount + 1); @@ -439,6 +444,7 @@ public static bool InputText( utf8LabelBytes = stackPtr; } Util.GetUtf8(label, utf8LabelBytes, utf8LabelByteCount); + utf8LabelBytes[utf8LabelByteCount] = 0; bool ret = ImGuiNative.igInputText(utf8LabelBytes, (byte*)buf.ToPointer(), buf_size, flags, callback, user_data.ToPointer()) != 0; @@ -464,6 +470,7 @@ public static bool Begin(ReadOnlySpan name, ImGuiWindowFlags flags) utf8NameBytes = stackPtr; } Util.GetUtf8(name, utf8NameBytes, utf8NameByteCount); + utf8NameBytes[utf8NameByteCount] = 0; byte* p_open = null; byte ret = ImGuiNative.igBegin(utf8NameBytes, p_open, flags); diff --git a/src/ImGui.NET/ImGui.Manual.cs b/src/ImGui.NET/ImGui.Manual.cs index 00c183d7..547c708e 100644 --- a/src/ImGui.NET/ImGui.Manual.cs +++ b/src/ImGui.NET/ImGui.Manual.cs @@ -54,6 +54,7 @@ public static bool InputText( utf8LabelBytes = stackPtr; } Util.GetUtf8(label, utf8LabelBytes, utf8LabelByteCount); + utf8LabelBytes[utf8LabelByteCount] = 0; bool ret; fixed (byte* bufPtr = buf) @@ -107,6 +108,7 @@ public static bool InputText( utf8LabelBytes = stackPtr; } Util.GetUtf8(label, utf8LabelBytes, utf8LabelByteCount); + utf8LabelBytes[utf8LabelByteCount] = 0; int utf8InputByteCount = Encoding.UTF8.GetByteCount(input); int inputBufSize = Math.Max((int)maxLength + 1, utf8InputByteCount + 1); @@ -197,6 +199,7 @@ public static bool InputTextMultiline( utf8LabelBytes = stackPtr; } Util.GetUtf8(label, utf8LabelBytes, utf8LabelByteCount); + utf8LabelBytes[utf8LabelByteCount] = 0; int utf8InputByteCount = Encoding.UTF8.GetByteCount(input); int inputBufSize = Math.Max((int)maxLength + 1, utf8InputByteCount + 1); @@ -288,6 +291,7 @@ public static bool InputTextWithHint( utf8LabelBytes = stackPtr; } Util.GetUtf8(label, utf8LabelBytes, utf8LabelByteCount); + utf8LabelBytes[utf8LabelByteCount] = 0; int utf8HintByteCount = Encoding.UTF8.GetByteCount(hint); byte* utf8HintBytes; @@ -301,6 +305,7 @@ public static bool InputTextWithHint( utf8HintBytes = stackPtr; } Util.GetUtf8(hint, utf8HintBytes, utf8HintByteCount); + utf8HintBytes[utf8HintByteCount] = 0; int utf8InputByteCount = Encoding.UTF8.GetByteCount(input); int inputBufSize = Math.Max((int)maxLength + 1, utf8InputByteCount + 1); @@ -435,6 +440,7 @@ public static bool InputText( utf8LabelBytes = stackPtr; } Util.GetUtf8(label, utf8LabelBytes, utf8LabelByteCount); + utf8LabelBytes[utf8LabelByteCount] = 0; bool ret = ImGuiNative.igInputText(utf8LabelBytes, (byte*)buf.ToPointer(), buf_size, flags, callback, user_data.ToPointer()) != 0; @@ -460,6 +466,7 @@ public static bool Begin(string name, ImGuiWindowFlags flags) utf8NameBytes = stackPtr; } Util.GetUtf8(name, utf8NameBytes, utf8NameByteCount); + utf8NameBytes[utf8NameByteCount] = 0; byte* p_open = null; byte ret = ImGuiNative.igBegin(utf8NameBytes, p_open, flags);