Fix an uninitialized memory access in json_pointer.

Add comments describing when the fields of the internal struct json_pointer_get_result are valid.
This commit is contained in:
Eric Hawicz
2023-07-26 18:15:07 -04:00
parent efc530594b
commit a14a3a680c
3 changed files with 16 additions and 16 deletions

View File

@@ -19,10 +19,11 @@ extern "C" {
struct json_pointer_get_result {
struct json_object *parent;
struct json_object *obj;
union {
const char *key;
uint32_t index;
} id;
// The key of the found object; only valid when parent is json_type_object
// Caution: re-uses tail end of the `path` argument to json_pointer_get_internal
const char *key_in_parent;
// the index of the found object; only valid when parent is json_type_array
uint32_t index_in_parent;
};
int json_pointer_get_internal(struct json_object *obj, const char *path,