mirror of
https://github.com/DaveGamble/cJSON
synced 2025-04-17 20:46:23 +00:00
Enforce sscanf-function return value check at print_number-function
This commit is contained in:
parent
424ce4ce96
commit
741e30cff6
7
cJSON.c
7
cJSON.c
@ -580,7 +580,12 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
|
||||
length = sprintf((char*)number_buffer, "%1.15g", d);
|
||||
|
||||
/* Check whether the original double can be recovered */
|
||||
if ((sscanf((char*)number_buffer, "%lg", &test) != 1) || !compare_double((double)test, d))
|
||||
if (sscanf((char*)number_buffer, "%lg", &test) != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!compare_double((double)test, d))
|
||||
{
|
||||
/* If not, print with 17 decimal places of precision */
|
||||
length = sprintf((char*)number_buffer, "%1.17g", d);
|
||||
|
Loading…
Reference in New Issue
Block a user