summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-03-04 15:48:36 +0100
committerJo-Philipp Wich <jo@mein.io>2021-03-08 17:11:49 +0100
commite88ed690d38beaf2b9919e2fc03223d33f24459a (patch)
tree8aa51fa0437d4a57199075ed39aff8825056394b
parentc433a31360612dfd5b263cea5afa8e2c8fbcca5b (diff)
vm: fix global scope refcount imbalance
The uc_vm_execute() API function decreases the refcount of the globals object when finishing but does not increase it initially which leads to a double free at main.c:155 Fix the issue by both increasing and decreasing the refcount. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--vm.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/vm.c b/vm.c
index 2889cce..cd71bc6 100644
--- a/vm.c
+++ b/vm.c
@@ -2182,6 +2182,7 @@ uc_vm_execute(uc_vm *vm, uc_function *fn, uc_prototype *globals, json_object *mo
uc_vm_status_t rv;
vm->globals = globals;
+ uc_value_get(globals ? globals->header.jso : NULL);
uc_vector_grow(&vm->callframes);