mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-08 20:07:56 -04:00
Clean up properly when adding a signal handler fails.
Previously, when a signation() or signal() call failed, we would free the element we added to sh_old, but not actually clear the pointer. This would leave a dangling pointer in sh_old that could cause a crash later.
This commit is contained in:
parent
899c1dcc98
commit
b84b598eae
2
signal.c
2
signal.c
@ -185,12 +185,14 @@ _evsig_set_handler(struct event_base *base,
|
||||
if (sigaction(evsignal, &sa, sig->sh_old[evsignal]) == -1) {
|
||||
event_warn("sigaction");
|
||||
mm_free(sig->sh_old[evsignal]);
|
||||
sig->sh_old[evsignal] = NULL;
|
||||
return (-1);
|
||||
}
|
||||
#else
|
||||
if ((sh = signal(evsignal, handler)) == SIG_ERR) {
|
||||
event_warn("signal");
|
||||
mm_free(sig->sh_old[evsignal]);
|
||||
sig->sh_old[evsignal] = NULL;
|
||||
return (-1);
|
||||
}
|
||||
*sig->sh_old[evsignal] = sh;
|
||||
|
Loading…
x
Reference in New Issue
Block a user