summaryrefslogtreecommitdiffhomepage
path: root/eval.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-09-13 21:37:06 +0200
committerJo-Philipp Wich <jo@mein.io>2020-09-13 21:37:06 +0200
commit8001ced3a088fc26a8c4e60dcd31dbba6c7b0eba (patch)
tree82ab4fbf9162d35b38ca26042e79e8502c03cd1c /eval.c
parent6778d654de4a2a97254684a8418f4464ec163a64 (diff)
eval: make key argument to ut_getref() optional
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c12
1 files changed, 8 insertions, 4 deletions
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;
}