diff options
| author | 2018-02-13 09:37:27 -0800 | |
|---|---|---|
| committer | 2018-02-13 10:18:53 -0800 | |
| commit | db43afcec22c11ce661decdd2b3500f2dfe2034a (patch) | |
| tree | 3ea9da8556b5a3c997ade26731a984f4b23d442e | |
| parent | fc7423bcba0678cc4a09ce19ec42830126107770 (diff) | |
Fix a bug in vector reverse iteration.
Bug: 73264895
Test: statsd_test and locally built statsd with
LOCAL_CLANG:=true
LOCAL_SANITIZE:=address
Change-Id: Ifb8e04c5b4908446f553169846a3226db6e02f54
| -rw-r--r-- | cmds/statsd/src/logd/LogEvent.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/cmds/statsd/src/logd/LogEvent.cpp b/cmds/statsd/src/logd/LogEvent.cpp index 909b74f30508..ce3a4b96b261 100644 --- a/cmds/statsd/src/logd/LogEvent.cpp +++ b/cmds/statsd/src/logd/LogEvent.cpp @@ -241,10 +241,10 @@ void LogEvent::init(android_log_context context) { // So that we can later easily match them with Position=Last matchers. pos[prevDepth]--; int path = getEncodedField(pos, prevDepth, false); - for (size_t j = mValues.size() - 1; j >= 0; j--) { - if (mValues[j].mField.getDepth() >= prevDepth && - mValues[j].mField.getPath(prevDepth) == path) { - mValues[j].mField.decorateLastPos(prevDepth); + for (auto it = mValues.rbegin(); it != mValues.rend(); ++it) { + if (it->mField.getDepth() >= prevDepth && + it->mField.getPath(prevDepth) == path) { + it->mField.decorateLastPos(prevDepth); } else { // Safe to break, because the items are in DFS order. break; |