Commit a57caedb authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

Fix NULL pointer dereferncing in AutoSigninFirstRunDialogView.

This is exactly the same crash and fix as in https://chromium-review.googlesource.com/c/chromium/src/+/951002/

The fix is for 3 different crashes.
- AutoSigninFirstRunDialogView::ControllerGone can trigger some accessibility events. The framework needs the title of the dialog. As a result the controller is dereferenced.
- AutoSigninFirstRunDialogView::Accept and AutoSigninFirstRunDialogView::Cancel. On Mac those events may be triggered when the dialog already disappeared. Therefore, a NULL-check is required before pinging the controller.

Bug: 904154
Change-Id: I58904340599227a5b06eb00a3d46f180bc2864a6
Reviewed-on: https://chromium-review.googlesource.com/c/1333659Reviewed-by: default avatarVaclav Brozek <vabr@chromium.org>
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607721}
parent 746e4da6
...@@ -33,8 +33,10 @@ void AutoSigninFirstRunDialogView::ShowAutoSigninPrompt() { ...@@ -33,8 +33,10 @@ void AutoSigninFirstRunDialogView::ShowAutoSigninPrompt() {
} }
void AutoSigninFirstRunDialogView::ControllerGone() { void AutoSigninFirstRunDialogView::ControllerGone() {
controller_ = nullptr; // During Widget::Close() phase some accessibility event may occur. Thus,
// |controller_| should be kept around.
GetWidget()->Close(); GetWidget()->Close();
controller_ = nullptr;
} }
ui::ModalType AutoSigninFirstRunDialogView::GetModalType() const { ui::ModalType AutoSigninFirstRunDialogView::GetModalType() const {
...@@ -62,12 +64,18 @@ void AutoSigninFirstRunDialogView::WindowClosing() { ...@@ -62,12 +64,18 @@ void AutoSigninFirstRunDialogView::WindowClosing() {
} }
bool AutoSigninFirstRunDialogView::Cancel() { bool AutoSigninFirstRunDialogView::Cancel() {
controller_->OnAutoSigninTurnOff(); // On Mac the button click event may be dispatched after the dialog was
// hidden. Thus, the controller can be NULL.
if (controller_)
controller_->OnAutoSigninTurnOff();
return true; return true;
} }
bool AutoSigninFirstRunDialogView::Accept() { bool AutoSigninFirstRunDialogView::Accept() {
controller_->OnAutoSigninOK(); // On Mac the button click event may be dispatched after the dialog was
// hidden. Thus, the controller can be NULL.
if (controller_)
controller_->OnAutoSigninOK();
return true; return true;
} }
......
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