Commit c0b83f5a authored by Avi Drissman's avatar Avi Drissman Committed by Nico Weber

Don't trust callbacks from the Rosetta installer

Every so often, the Rosetta installer will call back
the provided "installation done" block more than once.
Protect against that.

Fixed: 1150097
Change-Id: Ib12db225e7c7f5ec7c7fa69dccdd12693575a944
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2545076Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828484}
parent 4379e292
...@@ -138,11 +138,19 @@ void RequestRosettaInstallation( ...@@ -138,11 +138,19 @@ void RequestRosettaInstallation(
__block OnceCallback<void(RosettaInstallationResult)> block_callback = __block OnceCallback<void(RosettaInstallationResult)> block_callback =
std::move(callback); std::move(callback);
auto completion = ^(BOOL success) { auto completion = ^(BOOL success) {
[current_rosetta_installation release]; // There _should_ be a valid callback and current_rosetta_installation
current_rosetta_installation = nil; // here. However, crashes indicate that sometimes
std::move(block_callback) // OAHSoftwareUpdateController performs a double-callback of the block.
.Run(success ? RosettaInstallationResult::kInstallationSuccess // Therefore, be paranoid.
: RosettaInstallationResult::kInstallationFailure); if (current_rosetta_installation) {
[current_rosetta_installation release];
current_rosetta_installation = nil;
}
if (block_callback) {
std::move(block_callback)
.Run(success ? RosettaInstallationResult::kInstallationSuccess
: RosettaInstallationResult::kInstallationFailure);
}
}; };
[invocation setArgument:&completion atIndex:4]; [invocation setArgument:&completion atIndex:4];
......
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