Add guard for ASCII handler block
@@ -113,6 +113,8 @@ public static int transcodeToUTF16(byte[] utf8, char[] utf16)
byte codeUnit = utf8[i++];
if (codeUnit >= 0)
{
+ if (j >= utf16.length) { return -1; }
+
utf16[j++] = (char)codeUnit;
continue;
}
