From: Nick M. <ni...@us...> - 2010-08-23 15:58:51
|
Author: Nick Mathewson <ni...@to...> Date: Mon, 23 Aug 2010 12:01:45 -0400 Subject: Detect events with no ev_base; warn instead of crashing Commit: f1074b776a08aa1735752484e25377889140a622 --- event.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/event.c b/event.c index dc1079f..e18b3b9 100644 --- a/event.c +++ b/event.c @@ -1818,6 +1818,11 @@ event_add(struct event *ev, const struct timeval *tv) { int res; + if (EVUTIL_FAILURE_CHECK(!ev->ev_base)) { + event_warnx("%s: event has no event_base set.", __func__); + return -1; + } + EVBASE_ACQUIRE_LOCK(ev->ev_base, th_base_lock); res = event_add_internal(ev, tv, 0); @@ -2030,6 +2035,11 @@ event_del(struct event *ev) { int res; + if (EVUTIL_FAILURE_CHECK(!ev->ev_base)) { + event_warnx("%s: event has no event_base set.", __func__); + return -1; + } + EVBASE_ACQUIRE_LOCK(ev->ev_base, th_base_lock); res = event_del_internal(ev); @@ -2117,6 +2127,11 @@ event_del_internal(struct event *ev) void event_active(struct event *ev, int res, short ncalls) { + if (EVUTIL_FAILURE_CHECK(!ev->ev_base)) { + event_warnx("%s: event has no event_base set.", __func__); + return; + } + EVBASE_ACQUIRE_LOCK(ev->ev_base, th_base_lock); _event_debug_assert_is_setup(ev); -- 1.6.3 |