From f0c1b896bae0c7f83cdf49e11dc105cc808f1c16 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Wed, 28 Jun 2017 16:00:41 +0200 Subject: [PATCH] handle null pointers: cJSONUtils_GeneratePatches --- cJSON_Utils.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cJSON_Utils.c b/cJSON_Utils.c index e13b903..35fc450 100644 --- a/cJSON_Utils.c +++ b/cJSON_Utils.c @@ -1228,7 +1228,14 @@ static void create_patches(cJSON * const patches, const unsigned char * const pa CJSON_PUBLIC(cJSON *) cJSONUtils_GeneratePatches(cJSON * const from, cJSON * const to) { - cJSON *patches = cJSON_CreateArray(); + cJSON *patches = NULL; + + if ((from == NULL) || (to == NULL)) + { + return NULL; + } + + patches = cJSON_CreateArray(); create_patches(patches, (const unsigned char*)"", from, to, false); return patches;