diff --git a/cJSON.c b/cJSON.c index 3063f74..9d0b668 100644 --- a/cJSON.c +++ b/cJSON.c @@ -2540,7 +2540,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count) cJSON *p = NULL; cJSON *a = NULL; - if ((count < 0) || (numbers == NULL)) + if ((count < 0) || ((count > 0) && (numbers == NULL))) { return NULL; } @@ -2580,7 +2580,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count) cJSON *p = NULL; cJSON *a = NULL; - if ((count < 0) || (numbers == NULL)) + if ((count < 0) || ((count > 0) && (numbers == NULL))) { return NULL; } @@ -2620,7 +2620,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count) cJSON *p = NULL; cJSON *a = NULL; - if ((count < 0) || (numbers == NULL)) + if ((count < 0) || ((count > 0) && (numbers == NULL))) { return NULL; } @@ -2660,7 +2660,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int co cJSON *p = NULL; cJSON *a = NULL; - if ((count < 0) || (strings == NULL)) + if ((count < 0) || ((count > 0) && (strings == NULL))) { return NULL; }