Skip to content

Commit a22ed3f

Browse files
Fix potential crash for Encoder.Convert (#20522)
GetByteCount will not return the right number of bytes needed, so GetBytes in Encoder.Convert will crash for some input Backport of #20271. Co-authored-by: jeffgoku <jeffreygoku@gmail.com>
1 parent 9707837 commit a22ed3f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

mcs/class/I18N/CJK/GB18030Encoding.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,9 @@ public unsafe override int GetBytesImpl (char* chars, int charCount, byte* bytes
430430
}
431431
#else
432432

433-
public override int GetByteCount(char[] chars, int index, int count, bool refresh)
433+
public override int GetByteCount(char[] chars, int start, int count, bool refresh)
434434
{
435-
int start = 0;
436-
int end = count;
435+
int end = start + count;
437436
int ret = 0;
438437
while (start < end)
439438
{

0 commit comments

Comments
 (0)