Skip to content

Commit

Permalink
-Added length check to fix a parsing bug with certain values.
Browse files Browse the repository at this point in the history
  • Loading branch information
crookseta committed Dec 21, 2024
1 parent 8460f34 commit 6bb55f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
29 changes: 16 additions & 13 deletions src/MissingValues/Info/NumberParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,24 +201,27 @@ public static ParsingStatus ParseDecStringToUnsigned<T, TChar>(ReadOnlySpan<TCha
} while (true);

length = s.Length - i;
if (TChar.TryParseInteger(s[^length..], NumberStyles.Integer, CultureInfo.CurrentCulture, out r))
if (length != 0)
{
output *= T.CreateTruncating(E19Table[length]);
T addon = output + T.CreateTruncating(r);
if (addon < output)
if (TChar.TryParseInteger(s[^length..], NumberStyles.Integer, CultureInfo.CurrentCulture, out r))
{
output = default;
return ParsingStatus.Overflow;
output *= T.CreateTruncating(E19Table[length]);
T addon = output + T.CreateTruncating(r);
if (addon < output)
{
output = default;
return ParsingStatus.Overflow;
}
else
{
output = addon;
}
}
else
{
output = addon;
}
}
else
{
output = default;
return ParsingStatus.Failed;
output = default;
return ParsingStatus.Failed;
}
}

return ParsingStatus.Success;
Expand Down
2 changes: 1 addition & 1 deletion src/MissingValues/MissingValues.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReleaseNotes>https://github.com/crookseta/missing-values/releases</PackageReleaseNotes>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Version>2.1.1</Version>
<Version>2.1.2</Version>

<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
Expand Down

0 comments on commit 6bb55f0

Please sign in to comment.