mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
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:
parent
41c3ddf87c
commit
61eb599914
2
cJSON.c
2
cJSON.c
@ -333,10 +333,12 @@ loop_end:
|
||||
if (number >= INT_MAX)
|
||||
{
|
||||
item->valueint = INT_MAX;
|
||||
item->valuelong = (long)strtol((const char *)number_c_string, (char **)NULL, 10);
|
||||
}
|
||||
else if (number <= (double)INT_MIN)
|
||||
{
|
||||
item->valueint = INT_MIN;
|
||||
item->valuelong = (long)strtol((const char *)number_c_string, (char **)NULL, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user