This commit is contained in:
ZhaoYandong00 2023-07-06 08:28:07 +08:00 committed by GitHub
commit 5ffec39d1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -405,10 +405,13 @@ CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring)
{
return NULL;
}
if (strlen(valuestring) <= strlen(object->valuestring))
if (object->valuestring != NULL)
{
strcpy(object->valuestring, valuestring);
return object->valuestring;
if (strlen(valuestring) <= strlen(object->valuestring))
{
strcpy(object->valuestring, valuestring);
return object->valuestring;
}
}
copy = (char*) cJSON_strdup((const unsigned char*)valuestring, &global_hooks);
if (copy == NULL)