From 37afd37401253ebcebcf6e07ce15c8cfecb1a1cc Mon Sep 17 00:00:00 2001 From: Joshua Peraza Date: Tue, 20 Feb 2024 18:50:05 -0800 Subject: [PATCH] Properly update iterator Bug: 325296797 Change-Id: I39f76519c46804ad663172abf91ef582bde135e7 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5310754 Commit-Queue: Joshua Peraza Reviewed-by: Justin Cohen --- snapshot/sanitized/module_snapshot_sanitized.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/snapshot/sanitized/module_snapshot_sanitized.cc b/snapshot/sanitized/module_snapshot_sanitized.cc index 0ad2ee97..c7672268 100644 --- a/snapshot/sanitized/module_snapshot_sanitized.cc +++ b/snapshot/sanitized/module_snapshot_sanitized.cc @@ -99,9 +99,11 @@ ModuleSnapshotSanitized::AnnotationsSimpleMap() const { std::map annotations = snapshot_->AnnotationsSimpleMap(); if (allowed_annotations_) { - for (auto kv = annotations.begin(); kv != annotations.end(); ++kv) { - if (!KeyIsAllowed(kv->first, *allowed_annotations_)) { - annotations.erase(kv); + for (auto kv = annotations.begin(); kv != annotations.end();) { + if (KeyIsAllowed(kv->first, *allowed_annotations_)) { + ++kv; + } else { + kv = annotations.erase(kv); } } }