Clear Context in EventLoop at construction time
We were exposing uninitialized memory and hoping our users wouldn't try
to access it. This is an overly bold assumption.
Change-Id: I286fe5e932354581419059d128563c435b16071b
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/events/event_loop.cc b/aos/events/event_loop.cc
index df0390c..09a3834 100644
--- a/aos/events/event_loop.cc
+++ b/aos/events/event_loop.cc
@@ -89,6 +89,7 @@
context_.realtime_event_time = realtime_clock::min_time;
context_.realtime_remote_time = realtime_clock::min_time;
context_.queue_index = 0xffffffff;
+ context_.remote_queue_index = 0xffffffffu;
context_.size = 0;
context_.data = nullptr;
context_.buffer_index = -1;
@@ -600,6 +601,19 @@
return result;
}
+void EventLoop::ClearContext() {
+ context_.monotonic_event_time = monotonic_clock::min_time;
+ context_.monotonic_remote_time = monotonic_clock::min_time;
+ context_.realtime_event_time = realtime_clock::min_time;
+ context_.realtime_remote_time = realtime_clock::min_time;
+ context_.queue_index = 0xffffffffu;
+ context_.remote_queue_index = 0xffffffffu;
+ context_.size = 0u;
+ context_.data = nullptr;
+ context_.buffer_index = -1;
+ context_.source_boot_uuid = boot_uuid();
+}
+
void EventLoop::SetTimerContext(
monotonic_clock::time_point monotonic_event_time) {
context_.monotonic_event_time = monotonic_event_time;
@@ -607,6 +621,7 @@
context_.realtime_event_time = realtime_clock::min_time;
context_.realtime_remote_time = realtime_clock::min_time;
context_.queue_index = 0xffffffffu;
+ context_.remote_queue_index = 0xffffffffu;
context_.size = 0u;
context_.data = nullptr;
context_.buffer_index = -1;