diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-06-07 18:26:49 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-06-07 18:26:49 +0200 |
commit | 856a0c05fbbde4363634e7f8d5de7ed66d0e0cdc (patch) | |
tree | 40ae5b043c3a0aa6d27f482f869f43da0202e919 | |
parent | 86fb1300a500f6f49f1c6bb4f68c111106c862a5 (diff) |
lib: only consider context of calling function for callbacks
Do not walk up the entire call stack but specifically use the context of the
callframe calling the C function.
Fixes: 3e893e6 ("lib: pass-through "this" context to library function callbacks")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | lib.c | 9 |
1 files changed, 2 insertions, 7 deletions
@@ -266,14 +266,9 @@ static void uc_vm_ctx_push(uc_vm *vm) { uc_value_t *ctx = NULL; - size_t i; - for (i = vm->callframes.count; i > 0; i--) { - if (vm->callframes.entries[i - 1].ctx) { - ctx = vm->callframes.entries[i - 1].ctx; - break; - } - } + if (vm->callframes.count >= 2) + ctx = vm->callframes.entries[vm->callframes.count - 2].ctx; uc_vm_stack_push(vm, ucv_get(ctx)); } |