Add long values support

Some APIs like Telegram Bot API return responses with values that cannot be accepted with simple valueint. parse_number() function doesn't actually accept numbers larger than INT_MAX/INT_MIN - if the number is one of those (i.e larger than INT_MAX - integer overflow), the result of "item->valueint" will be INT_MAX. In case overflow, let it try storing the value anyways.
This commit is contained in:
ion 2020-01-13 15:55:07 +02:00 committed by GitHub
parent 41c3ddf87c
commit 61eb599914
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -333,10 +333,12 @@ loop_end:
if (number >= INT_MAX) if (number >= INT_MAX)
{ {
item->valueint = INT_MAX; item->valueint = INT_MAX;
item->valuelong = (long)strtol((const char *)number_c_string, (char **)NULL, 10);
} }
else if (number <= (double)INT_MIN) else if (number <= (double)INT_MIN)
{ {
item->valueint = INT_MIN; item->valueint = INT_MIN;
item->valuelong = (long)strtol((const char *)number_c_string, (char **)NULL, 10);
} }
else else
{ {