From 2c3e8f8e38fa2bb07519ca60d5b5efdf234aef32 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 2 Oct 2020 23:58:02 +0200 Subject: eval: avoid null pointer access in ut_invoke() Signed-off-by: Jo-Philipp Wich --- eval.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/eval.c b/eval.c index d6094ca..18fdf3c 100644 --- a/eval.c +++ b/eval.c @@ -1069,7 +1069,9 @@ ut_invoke(struct ut_state *state, uint32_t off, struct json_object *scope, /* store the function "this" context in the proto member of the scope tag structure */ tag = json_object_get_userdata(s); - tag->tag.proto = json_object_get(state->ctx); + + if (tag) + tag->tag.proto = json_object_get(state->ctx); rv = ut_execute_op_sequence(state, decl->tree.operand[2]); tag = json_object_get_userdata(rv); @@ -1097,8 +1099,11 @@ ut_invoke(struct ut_state *state, uint32_t off, struct json_object *scope, /* we left the function, remove the "this" context from the scope tag structure */ tag = json_object_get_userdata(s); - json_object_put(tag->tag.proto); - tag->tag.proto = NULL; + + if (tag) { + json_object_put(tag->tag.proto); + tag->tag.proto = NULL; + } if (!scope) { state->stack.scope[--state->stack.off] = NULL; -- cgit v1.2.3