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 <cgl.chenguolong@huawei.com>
(cherry picked from commit 968bbd5c918568eb95b493af05c464ddfc36671b)
This commit is contained in:
chenguolong 2020-02-04 16:05:02 +08:00 committed by Azat Khuzhin
parent 9e993c3cdb
commit 2e9ceb1655

View File

@ -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))