From 09fe97da3b0dcdb6ee172ff8e4f710e0baad2d1c Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 8 Jun 2011 14:24:45 -0400 Subject: [PATCH] Replace an assertion for event_base_free(NULL) with a check-and-warn event_base_free(NULL) means "free the current event base". Previously, it would assert if there was no 'current' base. Now it just warns and returns. Reported by Gilad Benjamini --- event.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/event.c b/event.c index 99d2eec5..27bf3dc3 100644 --- a/event.c +++ b/event.c @@ -681,13 +681,19 @@ event_base_free(struct event_base *base) /* XXXX grab the lock? If there is contention when one thread frees * the base, then the contending thread will be very sad soon. */ + /* event_base_free(NULL) is how to free the current_base if we + * made it with event_init and forgot to hold a reference to it. */ if (base == NULL && current_base) base = current_base; + /* If we're freeing current_base, there won't be a current_base. */ if (base == current_base) current_base = NULL; - + /* Don't actually free NULL. */ + if (base == NULL) { + event_warnx("%s: no base to free", __func__); + return; + } /* XXX(niels) - check for internal events first */ - EVUTIL_ASSERT(base); #ifdef WIN32 event_base_stop_iocp(base); -- 2.40.0