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
This commit is contained in:
David Chen
2017-11-22 16:47:59 -08:00
parent 916c83d227
commit c18abedfe2

View File

@@ -210,7 +210,7 @@ void SimpleConditionTracker::evaluateCondition(const LogEvent& event,
return;
}
if (mStopAllLogMatcherIndex >= 0 &&
if (mStopAllLogMatcherIndex >= 0 && mStopAllLogMatcherIndex < int(eventMatcherValues.size()) &&
eventMatcherValues[mStopAllLogMatcherIndex] == MatchingState::kMatched) {
handleStopAll(conditionCache, conditionChangedCache);
return;