diff options
author | Jo-Philipp Wich <jo@mein.io> | 2024-01-10 09:18:59 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2024-01-10 09:18:59 +0100 |
commit | 30a3f7ad0433be059f744c974917bc589b928682 (patch) | |
tree | c6186967ff89d897775e310ecfacac1db65c642a | |
parent | e8d4e4fe967d6b4f77e5820dafbe84676eb20b25 (diff) |
rtnl: store callback in listener registry only on success
Only store the callback reference in the registry once the listener
context was successfully initialized, to avoid keeping a lingering
entry when invalid parameters are passed.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | lib/rtnl.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -3707,9 +3707,9 @@ uc_nl_listener(uc_vm_t *vm, size_t nargs) break; } - ucv_array_set(listener_registry, i + 1, ucv_get(cb_func)); l = xalloc(sizeof(*l)); l->index = i; + if (!uc_nl_fill_cmds(l->cmds, cmds)) { uc_vm_raise_exception(vm, EXCEPTION_TYPE, "Invalid command ID"); free(l); @@ -3717,7 +3717,10 @@ uc_nl_listener(uc_vm_t *vm, size_t nargs) } rv = uc_resource_new(listener_type, l); + ucv_array_set(listener_registry, i, ucv_get(rv)); + ucv_array_set(listener_registry, i + 1, ucv_get(cb_func)); + listener_vm = vm; return rv; |