diff options
| author | 2018-03-19 23:07:06 +0000 | |
|---|---|---|
| committer | 2018-03-19 23:07:06 +0000 | |
| commit | 9859c29a8feafbb2b262b7ced99736e54e3a8b43 (patch) | |
| tree | 4e9431e4f48b879a0cf31b1a744a821df84ea539 | |
| parent | 88757bbb8b00464b237a0ffe3332e793c7e0c07c (diff) | |
| parent | 34900c3b4deb3a356997ab392234d74f8f0c3395 (diff) | |
Merge "Fix a UidMap crash." into pi-dev
| -rw-r--r-- | cmds/statsd/src/packages/UidMap.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cmds/statsd/src/packages/UidMap.cpp b/cmds/statsd/src/packages/UidMap.cpp index efbe96eebb25..e97d8b2af1ae 100644 --- a/cmds/statsd/src/packages/UidMap.cpp +++ b/cmds/statsd/src/packages/UidMap.cpp @@ -377,17 +377,20 @@ void UidMap::getOutput(const int64_t& timestamp, const ConfigKey& key, vector<ui if (newMin > prevMin) { // Delete anything possible now that the minimum has // moved forward. int64_t cutoff_nanos = newMin; - for (auto it_snapshots = mSnapshots.begin(); it_snapshots != mSnapshots.end(); - ++it_snapshots) { + for (auto it_snapshots = mSnapshots.begin(); it_snapshots != mSnapshots.end();) { if (it_snapshots->timestampNs < cutoff_nanos) { mBytesUsed -= it_snapshots->bytes.size() + kBytesTimestampField; - mSnapshots.erase(it_snapshots); + it_snapshots = mSnapshots.erase(it_snapshots); + } else { + ++it_snapshots; } } - for (auto it_changes = mChanges.begin(); it_changes != mChanges.end(); ++it_changes) { + for (auto it_changes = mChanges.begin(); it_changes != mChanges.end();) { if (it_changes->timestampNs < cutoff_nanos) { mBytesUsed -= kBytesChangeRecord; - mChanges.erase(it_changes); + it_changes = mChanges.erase(it_changes); + } else { + ++it_changes; } } |