diff --git a/cJSON.c b/cJSON.c index 88c2d95b..bba49acc 100644 --- a/cJSON.c +++ b/cJSON.c @@ -2511,7 +2511,11 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num) item->valuedouble = num; /* use saturation in case of overflow */ - if (num >= INT_MAX) + if (isnan(num) || isinf(num)) + { + item->valueint = 0; + } + else if (num >= INT_MAX) { item->valueint = INT_MAX; }