From 1df987a170a7d3c8692f53982eca0934d6e0e282 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Thu, 5 Jan 2017 21:31:17 +0100 Subject: [PATCH] cJSON_strdup: Check for NULL string --- cJSON.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cJSON.c b/cJSON.c index d0aad03..6ded617 100644 --- a/cJSON.c +++ b/cJSON.c @@ -88,6 +88,11 @@ static char* cJSON_strdup(const char* str) size_t len = 0; char *copy = NULL; + if (str == NULL) + { + return NULL; + } + len = strlen(str) + 1; if (!(copy = (char*)cJSON_malloc(len))) {