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
This commit is contained in:
Nick Mathewson 2012-11-16 11:55:27 -05:00
parent ac356502d3
commit e3cccf380c

View File

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