From e3cccf380c23891089d7c3a4637cac50010a600d Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 16 Nov 2012 11:55:27 -0500 Subject: [PATCH] Avoid crash when event_pending() called with no event_base set on event Instead, give a warning and return 0. Reported by Antony Dovgal on github as https://github.com/libevent/libevent/issues/19 --- event.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/event.c b/event.c index 91cb0cce..a979f1f2 100644 --- a/event.c +++ b/event.c @@ -1850,6 +1850,11 @@ event_pending(const struct event *ev, short event, struct timeval *tv) { int flags = 0; + if (EVUTIL_FAILURE_CHECK(ev->ev_base == NULL)) { + event_warnx("%s: event has no event_base set.", __func__); + return 0; + } + EVBASE_ACQUIRE_LOCK(ev->ev_base, th_base_lock); _event_debug_assert_is_setup(ev);