summaryrefslogtreecommitdiffhomepage
path: root/vm.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/vm.c b/vm.c
index 0c756d7..45e6f42 100644
--- a/vm.c
+++ b/vm.c
@@ -435,8 +435,10 @@ uc_vm_call_native(uc_vm_t *vm, uc_value_t *ctx, uc_cfunction_t *fptr, bool mcall
res = fptr->cfn(vm, nargs);
- /* reset stack */
- ucv_put(uc_vm_callframe_pop(vm));
+ /* Reset stack, check for callframe depth since an uncatched exception in managed
+ * code executed by fptr->cfn() could've reset the callframe stack already. */
+ if (vm->callframes.count > 0)
+ ucv_put(uc_vm_callframe_pop(vm));
/* push return value */
if (!vm->exception.type)