mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
fix: print_number didn't abort when out of memory
This commit is contained in:
parent
030d0c14cc
commit
cf1842dc6f
6
cJSON.c
6
cJSON.c
@ -372,8 +372,11 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
|
|||||||
|
|
||||||
/* This is a nice tradeoff. */
|
/* This is a nice tradeoff. */
|
||||||
output_pointer = ensure(output_buffer, 64, hooks);
|
output_pointer = ensure(output_buffer, 64, hooks);
|
||||||
if (output_pointer != NULL)
|
if (output_pointer == NULL)
|
||||||
{
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* This checks for NaN and Infinity */
|
/* This checks for NaN and Infinity */
|
||||||
if ((d * 0) != 0)
|
if ((d * 0) != 0)
|
||||||
{
|
{
|
||||||
@ -394,7 +397,6 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
|
|||||||
{
|
{
|
||||||
length = sprintf((char*)output_pointer, "%f", d);
|
length = sprintf((char*)output_pointer, "%f", d);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* sprintf failed */
|
/* sprintf failed */
|
||||||
if (length < 0)
|
if (length < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user