Commit 12993351 authored by Sigurdur Asgeirsson's avatar Sigurdur Asgeirsson Committed by Chromium LUCI CQ

ScopedObservation: CHECK on double observation.

Because base::ScopedObservation is strictly a singular observation,
it has exposed at least one latent release blocker bug on replacing
ScopedObserver. Unfortunately this manifested as a use-after-free, as
there was no test or build with DCHECK_IS_ON that covered this case.
See https://crbug.com/1153961#c14 for the details.

Bug: 1145565
Change-Id: Ibe198ca413e94676fa5dac3b94837b9999b3cb59
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2627763Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843641}
parent 9f4a6205
......@@ -56,7 +56,9 @@ class ScopedObservation {
// Adds the object passed to the constructor as an observer on |source|.
// IsObserving() must be false.
void Observe(Source* source) {
DCHECK_EQ(source_, nullptr);
// TODO(https://crbug.com/1145565): Make this a DCHECK once ScopedObserver
// has been fully retired.
CHECK_EQ(source_, nullptr);
source_ = source;
(source_->*AddObsFn)(observer_);
}
......
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