added checks for ArgumentOutOfRangeException

internals
Zaafar 4 years ago committed by Eric Mellino
parent 85d01be394
commit 5aae99ed9a
  1. 5
      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) 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) fixed (char* utf16Ptr = s)
{ {
return Encoding.UTF8.GetBytes(utf16Ptr + start, length, utf8Bytes, utf8ByteCount); return Encoding.UTF8.GetBytes(utf16Ptr + start, length, utf8Bytes, utf8ByteCount);

Loading…
Cancel
Save