mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-17 19:25:53 +02:00
Update JSON parser to correctly handle 64-bit integers
This commit is contained in:
@@ -575,18 +575,20 @@ void Parser::readValue(const Token* token)
|
|||||||
case Token::INTEGER_LITERAL_TOKEN:
|
case Token::INTEGER_LITERAL_TOKEN:
|
||||||
if ( _handler != NULL )
|
if ( _handler != NULL )
|
||||||
{
|
{
|
||||||
int value = token->asInteger();
|
|
||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
if ( value == std::numeric_limits<int>::max()
|
Int64 value = token->asInteger();
|
||||||
|| value == std::numeric_limits<int>::min() )
|
// if number is 32-bit, then handle as such
|
||||||
{
|
if ( value > std::numeric_limits<int>::max()
|
||||||
_handler->value(NumberParser::parse64(token->asString()));
|
|| value < std::numeric_limits<int>::min() )
|
||||||
}
|
{
|
||||||
else
|
_handler->value(value);
|
||||||
{
|
}
|
||||||
_handler->value(token->asInteger());
|
else
|
||||||
}
|
{
|
||||||
|
_handler->value(static_cast<int>(value));
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
|
int value = token->asInteger();
|
||||||
_handle->value(value);
|
_handle->value(value);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -697,5 +699,4 @@ bool Parser::readElements(bool firstCall)
|
|||||||
throw JSONException(format("Invalid token '%s' found.", token->asString()));
|
throw JSONException(format("Invalid token '%s' found.", token->asString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::JSON
|
} } // namespace Poco::JSON
|
||||||
|
Reference in New Issue
Block a user