Fixes out of range bug in SimpleConditionTracker.
One of the unit tests was flaky because mStopAllLogMatcherIndex may
be greater than the size of eventMatcherValues, so we access an
element that is greater than the vector size.
Test: Check unit-tests still work. Flake is a bit hard to find.
Change-Id: Ib177cd0ae00bbe7aa6982c6ec31d9094253a9c10
diff --git a/cmds/statsd/src/condition/SimpleConditionTracker.cpp b/cmds/statsd/src/condition/SimpleConditionTracker.cpp
index 60060fe..7e1c679 100644
--- a/cmds/statsd/src/condition/SimpleConditionTracker.cpp
+++ b/cmds/statsd/src/condition/SimpleConditionTracker.cpp
@@ -210,7 +210,7 @@
return;
}
- if (mStopAllLogMatcherIndex >= 0 &&
+ if (mStopAllLogMatcherIndex >= 0 && mStopAllLogMatcherIndex < int(eventMatcherValues.size()) &&
eventMatcherValues[mStopAllLogMatcherIndex] == MatchingState::kMatched) {
handleStopAll(conditionCache, conditionChangedCache);
return;