Skip to content

Commit 5aae99e

Browse files
zaafarmellinoe
authored andcommitted
added checks for ArgumentOutOfRangeException
1 parent 85d01be commit 5aae99e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/ImGui.NET/Util.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ internal static int GetUtf8(string s, byte* utf8Bytes, int utf8ByteCount)
5858

5959
internal static int GetUtf8(string s, int start, int length, byte* utf8Bytes, int utf8ByteCount)
6060
{
61+
if (start > s.Length - 1 || length > s.Length || start + length > s.Length)
62+
{
63+
throw new ArgumentOutOfRangeException();
64+
}
65+
6166
fixed (char* utf16Ptr = s)
6267
{
6368
return Encoding.UTF8.GetBytes(utf16Ptr + start, length, utf8Bytes, utf8ByteCount);

0 commit comments

Comments
 (0)