-Fixed not overflowing during integer parse

This commit is contained in:
James Newton-King
2013-04-23 01:05:30 +12:00
parent 6d109a4c55
commit 2bdf5c9b88
4 changed files with 102 additions and 2 deletions
@@ -619,7 +619,13 @@ namespace Newtonsoft.Json.Utilities
// go from negative to positive to avoids overflow
// negative can be slightly bigger than positive
if (!isNegative)
{
// negative integer can be one bigger than positive
if (result == int.MinValue)
throw new OverflowException();
result = -result;
}
return result;
}
@@ -664,7 +670,13 @@ namespace Newtonsoft.Json.Utilities
// go from negative to positive to avoids overflow
// negative can be slightly bigger than positive
if (!isNegative)
{
// negative integer can be one bigger than positive
if (value == long.MinValue)
return ParseResult.Overflow;
value = -value;
}
return ParseResult.Success;
}