]> git.feebdaed.xyz Git - 0xmirror/cJSON.git/commitdiff
Fix potential core dumped for strrchr (#546)
authorAlan Wang <wp_scut@163.com>
Thu, 31 Dec 2020 02:26:39 +0000 (10:26 +0800)
committerGitHub <noreply@github.com>
Thu, 31 Dec 2020 02:26:39 +0000 (10:26 +0800)
cJSON_Utils.c

index 8e70e003146183dc63b6d441a2b4305ba3cb5d74..c7c64391d56d86bc6cdc3700c97a21fbf22400a2 100644 (file)
@@ -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';