summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-10-02 23:58:02 +0200
committerJo-Philipp Wich <jo@mein.io>2020-10-02 23:58:02 +0200
commit2c3e8f8e38fa2bb07519ca60d5b5efdf234aef32 (patch)
treefc633fcc9680e7715610aa3d7bd6d4c0bbfc0124
parentd69fe00baba5f262dd0008ba01a4d4fa09c424a8 (diff)
eval: avoid null pointer access in ut_invoke()
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--eval.c11
1 files 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;