Skip to content

Commit

Permalink
Fix potential crash for Encoder.Convert (#20522)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
monojenkins and jeffgoku committed Oct 28, 2020
1 parent 9707837 commit a22ed3f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mcs/class/I18N/CJK/GB18030Encoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,9 @@ public unsafe override int GetBytesImpl (char* chars, int charCount, byte* bytes
}
#else

public override int GetByteCount(char[] chars, int index, int count, bool refresh)
public override int GetByteCount(char[] chars, int start, int count, bool refresh)
{
int start = 0;
int end = count;
int end = start + count;
int ret = 0;
while (start < end)
{
Expand Down

0 comments on commit a22ed3f

Please sign in to comment.