From 6b86aade15895d205f504ba70da93979bd6ee663 Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 27 Aug 2018 22:20:58 -0400 Subject: fix empty Event bug: redundant EventContext objects --- include/salticidae/event.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/salticidae/event.h b/include/salticidae/event.h index 9c59a6a..de8b4af 100644 --- a/include/salticidae/event.h +++ b/include/salticidae/event.h @@ -35,7 +35,7 @@ namespace salticidae { struct _event_context_deleter { constexpr _event_context_deleter() = default; void operator()(struct event_base *ptr) { - event_base_free(ptr); + if (ptr != nullptr) event_base_free(ptr); } }; @@ -44,6 +44,7 @@ using _event_context_ot = RcObj; class EventContext: public _event_context_ot { public: EventContext(): _event_context_ot(event_base_new()) {} + EventContext(struct event_base *eb): _event_context_ot(eb) {} EventContext(const EventContext &) = default; EventContext(EventContext &&) = default; EventContext &operator=(const EventContext &) = default; @@ -66,7 +67,7 @@ class Event { } public: - Event(): ev(nullptr) {} + Event(): eb(nullptr), ev(nullptr) {} Event(const EventContext &eb, evutil_socket_t fd, short events, -- cgit v1.2.3-70-g09d2