From 2e9ceb1655959638936a10938d864acf9cc7f016 Mon Sep 17 00:00:00 2001 From: chenguolong Date: Tue, 4 Feb 2020 16:05:02 +0800 Subject: [PATCH] event_base_once: fix potential null pointer threat supposing if base is null, EVBASE_ACQUIRE_LOCK and EVBASE_RELEASE_LOCK would get a coredump, so we add a guard for protection. Signed-off-by: chenguolong (cherry picked from commit 968bbd5c918568eb95b493af05c464ddfc36671b) --- event.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/event.c b/event.c index 31615886..7a42b731 100644 --- a/event.c +++ b/event.c @@ -2056,6 +2056,9 @@ event_base_once(struct event_base *base, evutil_socket_t fd, short events, int res = 0; int activate = 0; + if (!base) + return (-1); + /* We cannot support signals that just fire once, or persistent * events. */ if (events & (EV_SIGNAL|EV_PERSIST))