From 8001ced3a088fc26a8c4e60dcd31dbba6c7b0eba Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 13 Sep 2020 21:37:06 +0200 Subject: eval: make key argument to ut_getref() optional Signed-off-by: Jo-Philipp Wich --- eval.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'eval.c') diff --git a/eval.c b/eval.c index 001c614..5f4feb8 100644 --- a/eval.c +++ b/eval.c @@ -298,12 +298,14 @@ ut_getref(struct ut_state *state, uint32_t off, struct json_object **key) uint8_t i; if (op && op->type == T_DOT) { - *key = off2 ? ut_get_op(state, off2)->val : NULL; + if (key) + *key = off2 ? ut_get_op(state, off2)->val : NULL; return ut_execute_op(state, off1); } else if (op && op->type == T_LBRACK && op->is_postfix) { - *key = off2 ? ut_execute_op(state, off2) : NULL; + if (key) + *key = off2 ? ut_execute_op(state, off2) : NULL; return ut_execute_op(state, off1); } @@ -323,12 +325,14 @@ ut_getref(struct ut_state *state, uint32_t off, struct json_object **key) scope = next; } - *key = op->val; + if (key) + *key = op->val; return json_object_get(scope); } else { - *key = NULL; + if (key) + *key = NULL; return NULL; } -- cgit v1.2.3