diff options
author | Tanner Gooding <tagoo@outlook.com> | 2018-11-28 03:54:12 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-28 03:54:12 -0800 |
commit | e91cbf40efb743a859646e841ea168599dbd957e (patch) | |
tree | 64a15ce27cebb5c8fdfd8957a79a66f7ddf0c2fc /src/System.Private.CoreLib/shared/System/Buffers/Text/Utf8Parser | |
parent | 42ac3d30b1d8310e13eab6f42cc754fa53c5a01d (diff) | |
download | coreclr-e91cbf40efb743a859646e841ea168599dbd957e.tar.gz coreclr-e91cbf40efb743a859646e841ea168599dbd957e.tar.bz2 coreclr-e91cbf40efb743a859646e841ea168599dbd957e.zip |
Fixing up Utf8Parser.TryParseNumber to not fail for overly large exponents (#21233)
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/Buffers/Text/Utf8Parser')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Buffers/Text/Utf8Parser/Utf8Parser.Number.cs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Buffers/Text/Utf8Parser/Utf8Parser.Number.cs b/src/System.Private.CoreLib/shared/System/Buffers/Text/Utf8Parser/Utf8Parser.Number.cs index daa1da60a8..799a3fe6a7 100644 --- a/src/System.Private.CoreLib/shared/System/Buffers/Text/Utf8Parser/Utf8Parser.Number.cs +++ b/src/System.Private.CoreLib/shared/System/Buffers/Text/Utf8Parser/Utf8Parser.Number.cs @@ -303,10 +303,15 @@ namespace System.Buffers.Text { if (number.Scale > int.MaxValue - (long)absoluteExponent) { - bytesConsumed = 0; - return false; + // A scale overflow means all non-zero digits are all so far to the right of the decimal point, no + // number format we have will be able to see them. Just pin the scale at the absolute maximum + // and let the converter produce a 0 with the max precision available for that type. + number.Scale = int.MaxValue; + } + else + { + number.Scale += (int)absoluteExponent; } - number.Scale += (int)absoluteExponent; } digits[dstIndex] = 0; |