From 5aae99ed9ad3215e2cb6c969f82b7039eddec803 Mon Sep 17 00:00:00 2001 From: Zaafar Date: Fri, 25 Dec 2020 04:54:25 -0500 Subject: [PATCH] added checks for ArgumentOutOfRangeException --- src/ImGui.NET/Util.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ImGui.NET/Util.cs b/src/ImGui.NET/Util.cs index 1753d30..f0f71d1 100644 --- a/src/ImGui.NET/Util.cs +++ b/src/ImGui.NET/Util.cs @@ -58,6 +58,11 @@ namespace ImGuiNET internal static int GetUtf8(string s, int start, int length, byte* utf8Bytes, int utf8ByteCount) { + if (start > s.Length - 1 || length > s.Length || start + length > s.Length) + { + throw new ArgumentOutOfRangeException(); + } + fixed (char* utf16Ptr = s) { return Encoding.UTF8.GetBytes(utf16Ptr + start, length, utf8Bytes, utf8ByteCount);