Prevent use of invalidated iterator
If the underlying container changes, such as by deleting an element from
it, all of the outstanding iterators get invalidated.
Currently in EventHub, we are using a for loop to go through the entire
map, and deleting the map contents from inside this loop.
To avoid this, do not store the iterators explicitly.
Bug: 163171599
Test: atest inputflinger_tests:EventHubTest#InputEvent_TimestampIsMonotonic
Test: atest inputflinger_tests
Change-Id: I3af0721d54cc03668a68848f6f690a2d523e809b
diff --git a/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp b/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp
index b31980b..f99fffe 100644
--- a/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp
+++ b/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp
@@ -103,7 +103,7 @@
class FakeInputReceiver {
public:
void consumeEvent() {
- uint32_t consumeSeq;
+ uint32_t consumeSeq = 0;
InputEvent* event;
std::chrono::time_point start = std::chrono::steady_clock::now();