Commit 169dd605 authored by Maksim Ivanov's avatar Maksim Ivanov Committed by Commit Bot

Fix use-after-move in blink/renderer/modules/service_worker/

Fix use-after-move (potential) bugs found by the
"bugprone-use-after-move" clang-tidy check.

Bug: 1122844
Change-Id: I2bd90e9b1d358b641ffbc4824f5360f179962ee1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2401032Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Commit-Queue: Maksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805730}
parent 37f96585
...@@ -579,9 +579,10 @@ ServiceWorkerContainer::GetOrCreateServiceWorkerRegistration( ...@@ -579,9 +579,10 @@ ServiceWorkerContainer::GetOrCreateServiceWorkerRegistration(
return registration; return registration;
} }
const int64_t registration_id = info.registration_id;
registration = MakeGarbageCollected<ServiceWorkerRegistration>( registration = MakeGarbageCollected<ServiceWorkerRegistration>(
GetSupplementable()->GetExecutionContext(), std::move(info)); GetSupplementable()->GetExecutionContext(), std::move(info));
service_worker_registration_objects_.Set(info.registration_id, registration); service_worker_registration_objects_.Set(registration_id, registration);
return registration; return registration;
} }
...@@ -591,9 +592,10 @@ ServiceWorker* ServiceWorkerContainer::GetOrCreateServiceWorker( ...@@ -591,9 +592,10 @@ ServiceWorker* ServiceWorkerContainer::GetOrCreateServiceWorker(
return nullptr; return nullptr;
ServiceWorker* worker = service_worker_objects_.at(info.version_id); ServiceWorker* worker = service_worker_objects_.at(info.version_id);
if (!worker) { if (!worker) {
const int64_t version_id = info.version_id;
worker = ServiceWorker::Create(GetSupplementable()->GetExecutionContext(), worker = ServiceWorker::Create(GetSupplementable()->GetExecutionContext(),
std::move(info)); std::move(info));
service_worker_objects_.Set(info.version_id, worker); service_worker_objects_.Set(version_id, worker);
} }
return worker; return worker;
} }
......
...@@ -710,8 +710,9 @@ ServiceWorker* ServiceWorkerGlobalScope::GetOrCreateServiceWorker( ...@@ -710,8 +710,9 @@ ServiceWorker* ServiceWorkerGlobalScope::GetOrCreateServiceWorker(
return nullptr; return nullptr;
::blink::ServiceWorker* worker = service_worker_objects_.at(info.version_id); ::blink::ServiceWorker* worker = service_worker_objects_.at(info.version_id);
if (!worker) { if (!worker) {
const int64_t version_id = info.version_id;
worker = ::blink::ServiceWorker::Create(this, std::move(info)); worker = ::blink::ServiceWorker::Create(this, std::move(info));
service_worker_objects_.Set(info.version_id, worker); service_worker_objects_.Set(version_id, worker);
} }
return worker; return worker;
} }
......
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