]> granicus.if.org Git - libevent/commitdiff
event_base_once: fix potential null pointer threat
authorchenguolong <cgl.chenguolong@huawei.com>
Tue, 4 Feb 2020 08:05:02 +0000 (16:05 +0800)
committerAzat Khuzhin <azat@libevent.org>
Sat, 15 Feb 2020 23:54:15 +0000 (02:54 +0300)
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 <cgl.chenguolong@huawei.com>
event.c

diff --git a/event.c b/event.c
index ff4e79c8449a26d01d06b5851b3618688714273e..29a2c6d560d87a5990eb0d246221e073b556be9e 100644 (file)
--- a/event.c
+++ b/event.c
@@ -2091,6 +2091,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))