aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2018-08-27 22:20:58 -0400
committerDeterminant <[email protected]>2018-08-27 22:20:58 -0400
commit6b86aade15895d205f504ba70da93979bd6ee663 (patch)
tree29890494ce9dd1e989a1ef4e21fd69c4be6aac30
parent824afd167a52dfc3b39d96ebae1c91a5c69d4099 (diff)
fix empty Event bug: redundant EventContext objects
-rw-r--r--include/salticidae/event.h5
1 files 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<struct event_base, _event_context_deleter>;
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,