From 6ea4c01e4e6ff579de0ae4a5f44768307cbb9c69 Mon Sep 17 00:00:00 2001 From: Alan Wang Date: Thu, 31 Dec 2020 10:26:39 +0800 Subject: [PATCH] Fix potential core dumped for strrchr (#546) --- cJSON_Utils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cJSON_Utils.c b/cJSON_Utils.c index 8e70e00..c7c6439 100644 --- a/cJSON_Utils.c +++ b/cJSON_Utils.c @@ -960,7 +960,9 @@ static int apply_patch(cJSON *object, const cJSON *patch, const cJSON_bool case_ /* split pointer in parent and child */ parent_pointer = cJSONUtils_strdup((unsigned char*)path->valuestring); - child_pointer = (unsigned char*)strrchr((char*)parent_pointer, '/'); + if (parent_pointer) { + child_pointer = (unsigned char*)strrchr((char*)parent_pointer, '/'); + } if (child_pointer != NULL) { child_pointer[0] = '\0';