Skip to content

Commit

Permalink
Fixing Utf8Parser.Number to not modify the value of 'c' (dotnet/corec…
Browse files Browse the repository at this point in the history
…lr#20967)

Commit migrated from dotnet/coreclr@af659af
  • Loading branch information
tannergooding authored Nov 13, 2018
1 parent 30206f7 commit cf760d8
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ private static bool TryParseNumber(ReadOnlySpan<byte> source, ref Number.NumberB
while (srcIndex != source.Length)
{
c = source[srcIndex];
int value = (byte)(c - (byte)('0'));

if ((c -= (byte)('0')) > 9)
if (value > 9)
{
break;
}
Expand All @@ -102,7 +103,7 @@ private static bool TryParseNumber(ReadOnlySpan<byte> source, ref Number.NumberB
// for an input that falls evenly between two representable
// results.

hasNonZeroTail |= c;
hasNonZeroTail |= value;
}
}
number.HasNonZeroTail = (hasNonZeroTail != 0);
Expand Down Expand Up @@ -138,8 +139,9 @@ private static bool TryParseNumber(ReadOnlySpan<byte> source, ref Number.NumberB
while (srcIndex != source.Length)
{
c = source[srcIndex];
int value = (byte)(c - (byte)('0'));

if ((c -= (byte)('0')) > 9)
if (value > 9)
{
break;
}
Expand All @@ -156,7 +158,7 @@ private static bool TryParseNumber(ReadOnlySpan<byte> source, ref Number.NumberB
// for an input that falls evenly between two representable
// results.

hasNonZeroTail |= c;
hasNonZeroTail |= value;
}
}
number.HasNonZeroTail = (hasNonZeroTail != 0);
Expand Down

0 comments on commit cf760d8

Please sign in to comment.