mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Utils: PatchDetach: Check for invalid patch string
This commit is contained in:
parent
a2309a509d
commit
ff0681e4fd
@ -234,12 +234,19 @@ static cJSON *cJSONUtils_PatchDetach(cJSON *object, const char *path)
|
|||||||
|
|
||||||
/* copy path and split it in parent and child */
|
/* copy path and split it in parent and child */
|
||||||
parentptr = cJSONUtils_strdup(path);
|
parentptr = cJSONUtils_strdup(path);
|
||||||
childptr = strrchr(parentptr, '/'); /* last '/' */
|
if (parentptr == NULL) {
|
||||||
if (childptr)
|
return NULL;
|
||||||
{
|
|
||||||
/* split strings */
|
|
||||||
*childptr++ = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
childptr = strrchr(parentptr, '/'); /* last '/' */
|
||||||
|
if (childptr == NULL)
|
||||||
|
{
|
||||||
|
free(parentptr);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* split strings */
|
||||||
|
*childptr++ = '\0';
|
||||||
|
|
||||||
parent = cJSONUtils_GetPointer(object, parentptr);
|
parent = cJSONUtils_GetPointer(object, parentptr);
|
||||||
cJSONUtils_InplaceDecodePointerString(childptr);
|
cJSONUtils_InplaceDecodePointerString(childptr);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user