diff --git a/cJSON.c b/cJSON.c index f6dd11c5..f2204384 100644 --- a/cJSON.c +++ b/cJSON.c @@ -405,7 +405,7 @@ CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring) { return NULL; } - if (strlen(valuestring) <= strlen(object->valuestring)) + if (object->valuestring && (strlen(valuestring) <= strlen(object->valuestring))) { strcpy(object->valuestring, valuestring); return object->valuestring;