Commit f907b70b authored by Swapnil's avatar Swapnil Committed by Commit Bot

Fix InstallStageTracker::NotifyObserversOfFailure

InstallStageTracker::Observer::OnExtensionInstallationFailed may remove
the observers and thus change the object. Immediately after calling
this method, OnExtensionDataChangedForTesting method is called which
might result in a crash. The observers list is traversed again after
calling the method OnExtensionInstallationFailed so that only
the updated observers are used.

Bug: 1097700
Change-Id: I0c0721179d8b737e14748b2d5965926ad6a1bf88
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2257318
Commit-Queue: Swapnil Gupta <swapnilgupta@google.com>
Reviewed-by: default avatarOleg Davydov <burunduk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781397}
parent 533f873d
......@@ -253,10 +253,12 @@ void InstallStageTracker::NotifyObserversOfFailure(
const ExtensionId& id,
FailureReason reason,
const InstallationData& data) {
for (auto& observer : observers_) {
for (auto& observer : observers_)
observer.OnExtensionInstallationFailed(id, reason);
// Observer::OnExtensionInstallationFailed may change |observers_|, run the
// loop again to call the other methods for |observers_|.
for (auto& observer : observers_)
observer.OnExtensionDataChangedForTesting(id, browser_context_, data);
}
}
} // namespace extensions
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment