Skip to content

Commit

Permalink
Fix potential core dumped for strrchr (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alanscut authored Dec 31, 2020
1 parent 9226e4e commit 6ea4c01
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cJSON_Utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 6ea4c01

Please sign in to comment.