diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-06-08 14:24:45 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-06-08 14:24:45 -0400 |
commit | 09fe97da3b0dcdb6ee172ff8e4f710e0baad2d1c (patch) | |
tree | a715b0a6e9dd9d0cab4b1373077d3c7d4de2702f /event.c | |
parent | 89d5e09e4d3a4666bf5eba7d6807e183e861a70a (diff) | |
download | libevent-09fe97da3b0dcdb6ee172ff8e4f710e0baad2d1c.tar.gz |
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
Diffstat (limited to 'event.c')
-rw-r--r-- | event.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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); |