You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chromium/chromium-87-ServiceWorkerCo...

23 lines
1.1 KiB

4 years ago
Bug: https://bugs.gentoo.org/750038
Upstream bug: https://crbug.com/1135070
--- a/content/browser/service_worker/service_worker_container_host.cc
+++ b/content/browser/service_worker/service_worker_container_host.cc
@@ -626,6 +626,16 @@
int64_t registration_id) {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
DCHECK(base::Contains(registration_object_hosts_, registration_id));
+
+ // ServiceWorkerRegistrationObjectHost to be deleted may have the last reference to
+ // ServiceWorkerRegistration that indirectly owns this ServiceWorkerContainerHost.
+ // If we erase the object host directly from the map, |this| could be deleted
+ // during the map operation and may crash. To avoid the case, we take the
+ // ownership of the object host from the map first, and then erase the entry
+ // from the map. See https://crbug.com/1135070 for details.
+ std::unique_ptr<ServiceWorkerRegistrationObjectHost> to_be_deleted =
+ std::move(registration_object_hosts_[registration_id]);
+ DCHECK(to_be_deleted);
registration_object_hosts_.erase(registration_id);
}