summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-03-02 00:06:19 +0100
committerJo-Philipp Wich <jo@mein.io>2022-03-02 00:06:19 +0100
commit6b6d01f017bcac70aa0050d12e8e8c83f63fc13b (patch)
tree85422cc1e86d95e9912b9766bba5367413a8c42b
parent1af23a9db98575eecfc97e01e8f581221d1a224b (diff)
vm: release this context on exception in managed method call
When attempting to invoke a non-function value as method or when the the internal recursion limit was exceeded, `uc_vm_call_function()` emitted and internal runtime exception and freed the function value but not the `this` context associated with the method call. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--vm.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/vm.c b/vm.c
index e0cac6f..e29a6ed 100644
--- a/vm.c
+++ b/vm.c
@@ -459,6 +459,7 @@ uc_vm_call_function(uc_vm_t *vm, uc_value_t *ctx, uc_value_t *fno, bool mcall, s
/* XXX: make dependent on stack size */
if (vm->callframes.count >= 1000) {
uc_vm_raise_exception(vm, EXCEPTION_RUNTIME, "Too much recursion");
+ ucv_put(ctx);
ucv_put(fno);
return false;
@@ -528,6 +529,7 @@ uc_vm_call_function(uc_vm_t *vm, uc_value_t *ctx, uc_value_t *fno, bool mcall, s
if (ucv_type(fno) != UC_CLOSURE) {
uc_vm_raise_exception(vm, EXCEPTION_TYPE, "left-hand side is not a function");
+ ucv_put(ctx);
ucv_put(fno);
return false;