mirror of
https://github.com/json-c/json-c.git
synced 2026-09-07 16:46:50 +08:00
require string type for patch op/path/from fields
This commit is contained in:
+5
-3
@@ -208,7 +208,7 @@ static int json_patch_apply_move_copy(struct json_object **res,
|
||||
return -1;
|
||||
}
|
||||
|
||||
from_s = json_object_get_string(jfrom);
|
||||
from_s = json_object_get_type(jfrom) == json_type_string ? json_object_get_string(jfrom) : NULL;
|
||||
if (from_s == NULL) {
|
||||
_set_err(EINVAL, "Patch object 'from' field is not a string");
|
||||
return -1;
|
||||
@@ -323,7 +323,7 @@ int json_patch_apply(struct json_object *copy_from, struct json_object *patch,
|
||||
_set_err(EINVAL, "Patch object does not contain 'op' field");
|
||||
return -1;
|
||||
}
|
||||
op = json_object_get_string(jop);
|
||||
op = json_object_get_type(jop) == json_type_string ? json_object_get_string(jop) : NULL;
|
||||
if (op == NULL) {
|
||||
_set_err(EINVAL, "Patch object 'op' field is not a string");
|
||||
return -1;
|
||||
@@ -332,7 +332,9 @@ int json_patch_apply(struct json_object *copy_from, struct json_object *patch,
|
||||
_set_err(EINVAL, "Patch object does not contain 'path' field");
|
||||
return -1;
|
||||
}
|
||||
path = json_object_get_string(jpath); // Note: empty string is ok!
|
||||
// Note: empty string is ok!
|
||||
path = json_object_get_type(jpath) == json_type_string ? json_object_get_string(jpath)
|
||||
: NULL;
|
||||
if (path == NULL) {
|
||||
_set_err(EINVAL, "Patch object 'path' field is not a string");
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user