From 57f85f91cef0c56498736010170279107b67dd24 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 2 Dec 2012 14:57:43 +0100 Subject: [PATCH] eloop: fix memory loop when signal registration fails If the signal-registration fails, we need to destroy it again. Otherwise, it will keep a reference to the current eloop-object and hence it will never get freed. Signed-off-by: David Herrmann --- src/eloop.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/eloop.c b/src/eloop.c index 0601c67..307efcd 100644 --- a/src/eloop.c +++ b/src/eloop.c @@ -2186,7 +2186,13 @@ int ev_eloop_register_signal_cb(struct ev_eloop *loop, int signum, return ret; } - return shl_hook_add_cast(sig->hook, cb, data); + ret = shl_hook_add_cast(sig->hook, cb, data); + if (ret) { + signal_free(sig); + return ret; + } + + return 0; } /**