Skip to content

Commit 6bb55f0

Browse files
committed
-Added length check to fix a parsing bug with certain values.
1 parent 8460f34 commit 6bb55f0

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

src/MissingValues/Info/NumberParser.cs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -201,24 +201,27 @@ public static ParsingStatus ParseDecStringToUnsigned<T, TChar>(ReadOnlySpan<TCha
201201
} while (true);
202202

203203
length = s.Length - i;
204-
if (TChar.TryParseInteger(s[^length..], NumberStyles.Integer, CultureInfo.CurrentCulture, out r))
204+
if (length != 0)
205205
{
206-
output *= T.CreateTruncating(E19Table[length]);
207-
T addon = output + T.CreateTruncating(r);
208-
if (addon < output)
206+
if (TChar.TryParseInteger(s[^length..], NumberStyles.Integer, CultureInfo.CurrentCulture, out r))
209207
{
210-
output = default;
211-
return ParsingStatus.Overflow;
208+
output *= T.CreateTruncating(E19Table[length]);
209+
T addon = output + T.CreateTruncating(r);
210+
if (addon < output)
211+
{
212+
output = default;
213+
return ParsingStatus.Overflow;
214+
}
215+
else
216+
{
217+
output = addon;
218+
}
212219
}
213220
else
214221
{
215-
output = addon;
216-
}
217-
}
218-
else
219-
{
220-
output = default;
221-
return ParsingStatus.Failed;
222+
output = default;
223+
return ParsingStatus.Failed;
224+
}
222225
}
223226

224227
return ParsingStatus.Success;

src/MissingValues/MissingValues.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<PackageReleaseNotes>https://github.com/crookseta/missing-values/releases</PackageReleaseNotes>
1818
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1919
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
20-
<Version>2.1.1</Version>
20+
<Version>2.1.2</Version>
2121

2222
<IncludeSymbols>True</IncludeSymbols>
2323
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

0 commit comments

Comments
 (0)