From 2d252ae5957d5ddd43934822300c235ff154b4b6 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Wed, 28 Jun 2017 16:00:14 +0200 Subject: [PATCH] handle null pointer: compose_patch --- cJSON_Utils.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cJSON_Utils.c b/cJSON_Utils.c index 3e317ae..e13b903 100644 --- a/cJSON_Utils.c +++ b/cJSON_Utils.c @@ -1043,7 +1043,14 @@ CJSON_PUBLIC(int) cJSONUtils_ApplyPatchesCaseSensitive(cJSON * const object, con static void compose_patch(cJSON * const patches, const unsigned char * const operation, const unsigned char * const path, const unsigned char *suffix, const cJSON * const value) { - cJSON *patch = cJSON_CreateObject(); + cJSON *patch = NULL; + + if ((patches == NULL) || (operation == NULL) || (path == NULL)) + { + return; + } + + patch = cJSON_CreateObject(); if (patch == NULL) { return;