summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2024-01-10 09:18:59 +0100
committerJo-Philipp Wich <jo@mein.io>2024-01-10 09:18:59 +0100
commit30a3f7ad0433be059f744c974917bc589b928682 (patch)
treec6186967ff89d897775e310ecfacac1db65c642a /lib
parente8d4e4fe967d6b4f77e5820dafbe84676eb20b25 (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>
Diffstat (limited to 'lib')
-rw-r--r--lib/rtnl.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/rtnl.c b/lib/rtnl.c
index b6add37..663e634 100644
--- a/lib/rtnl.c
+++ b/lib/rtnl.c
@@ -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;