Fix potential core dumped for strrchr (#546)

This commit is contained in:
Alan Wang 2020-12-31 10:26:39 +08:00 committed by GitHub
parent 9226e4ed8c
commit 6ea4c01e4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View 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';