]> granicus.if.org Git - libevent/commitdiff
Avoid event_del on uninitialized event in event_base_free
authorNick Mathewson <nickm@torproject.org>
Thu, 13 May 2010 18:59:33 +0000 (14:59 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 13 May 2010 19:40:43 +0000 (15:40 -0400)
This was mostly harmless, since the event was cleared with calloc, but
still it's not a correct thing to do.

event.c

diff --git a/event.c b/event.c
index f7b69f52f72d61593806ffea6f189f2a28e0840a..eecabbe221124bd424ae3f8c23a4231600b07693 100644 (file)
--- a/event.c
+++ b/event.c
@@ -533,7 +533,6 @@ event_base_new_with_config(const struct event_config *cfg)
                event_warn("%s: calloc", __func__);
                return NULL;
        }
-
        detect_monotonic();
        gettime(base, &base->event_tv);
 
@@ -541,6 +540,8 @@ event_base_new_with_config(const struct event_config *cfg)
        TAILQ_INIT(&base->eventqueue);
        base->sig.ev_signal_pair[0] = -1;
        base->sig.ev_signal_pair[1] = -1;
+       base->th_notify_fd[0] = -1;
+       base->th_notify_fd[1] = -1;
 
        event_deferred_cb_queue_init(&base->defer_queue);
        base->defer_queue.notify_fn = notify_base_cbq_callback;
@@ -595,8 +596,6 @@ event_base_new_with_config(const struct event_config *cfg)
        }
 
        /* prepare for threading */
-       base->th_notify_fd[0] = -1;
-       base->th_notify_fd[1] = -1;
 
 #ifndef _EVENT_DISABLE_THREAD_SUPPORT
        if (!cfg || !(cfg->flags & EVENT_BASE_FLAG_NOLOCK)) {