Commit de3e7829 authored by Maksim Ivanov's avatar Maksim Ivanov Committed by Commit Bot

Fix use-after-move in //content/browser/background_sync/

Fix double-callback-call crash and use-after-move (potential)
bugs found by the "bugprone-use-after-move" clang-tidy check.

Bug: 1122844
Change-Id: I2da08b89a3dbab954caee4aa273f19ea958fa226
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2383019
Commit-Queue: Maksim Ivanov <emaxx@chromium.org>
Reviewed-by: default avatarMugdha Lakhani <nator@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803503}
parent 7cdbc311
...@@ -1920,6 +1920,7 @@ void BackgroundSyncManager::ReviveDidStoreRegistration( ...@@ -1920,6 +1920,7 @@ void BackgroundSyncManager::ReviveDidStoreRegistration(
// The service worker registration is gone. // The service worker registration is gone.
active_registrations_.erase(service_worker_registration_id); active_registrations_.erase(service_worker_registration_id);
std::move(done_closure).Run(); std::move(done_closure).Run();
return;
} }
if (status != blink::ServiceWorkerStatusCode::kOk) { if (status != blink::ServiceWorkerStatusCode::kOk) {
......
...@@ -361,14 +361,14 @@ class BackgroundSyncManagerTest ...@@ -361,14 +361,14 @@ class BackgroundSyncManagerTest
if (GetBackgroundSyncType(options) == if (GetBackgroundSyncType(options) ==
blink::mojom::BackgroundSyncType::ONE_SHOT) { blink::mojom::BackgroundSyncType::ONE_SHOT) {
test_background_sync_manager()->Register( test_background_sync_manager()->Register(
sw_registration_id, std::move(options), sw_registration_id, options,
base::BindOnce(&BackgroundSyncManagerTest:: base::BindOnce(&BackgroundSyncManagerTest::
StatusAndOneShotSyncRegistrationCallback, StatusAndOneShotSyncRegistrationCallback,
base::Unretained(this), &was_called)); base::Unretained(this), &was_called));
callback_status = &one_shot_sync_callback_status_; callback_status = &one_shot_sync_callback_status_;
} else { } else {
test_background_sync_manager()->Register( test_background_sync_manager()->Register(
sw_registration_id, std::move(options), sw_registration_id, options,
base::BindOnce(&BackgroundSyncManagerTest:: base::BindOnce(&BackgroundSyncManagerTest::
StatusAndPeriodicSyncRegistrationCallback, StatusAndPeriodicSyncRegistrationCallback,
base::Unretained(this), &was_called)); base::Unretained(this), &was_called));
......
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