Compare commits

...

2 Commits

Author SHA1 Message Date
Zhao Zhixu dbb92ccfec
Merge 5da11d6bea into f66cbab4bf 2023-12-23 13:48:53 +01:00
Zhixu Zhao 5da11d6bea Support creating empty arrays with cJSON_Create*Array(). 2021-12-14 00:05:39 +08:00
1 changed files with 4 additions and 4 deletions

View File

@ -2559,7 +2559,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;
}
@ -2599,7 +2599,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;
}
@ -2639,7 +2639,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;
}
@ -2679,7 +2679,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;
}