FirstBootPrompt: some NULL pointer checks

Should fix #16525
This commit is contained in:
Adrien Destugues
2020-09-20 18:52:45 +02:00
parent e2ee966fc0
commit e6f60cad2a
+14 -6
View File
@@ -305,8 +305,13 @@ BootPromptWindow::MessageReceived(BMessage* message)
bool bool
BootPromptWindow::QuitRequested() BootPromptWindow::QuitRequested()
{ {
if (!be_roster->IsRunning(kDeskbarSignature) && BMessage* message = CurrentMessage();
!CurrentMessage()->GetBool("dont_reboot")) bool dont_reboot = false;
if (message != NULL)
dont_reboot = message->GetBool("dont_reboot");
if (!be_roster->IsRunning(kDeskbarSignature) && !dont_reboot)
{ {
// If the Deskbar is not running, then FirstBootPrompt is // If the Deskbar is not running, then FirstBootPrompt is
// is the only thing visible on the screen and that we won't // is the only thing visible on the screen and that we won't
@@ -316,15 +321,18 @@ BootPromptWindow::QuitRequested()
// //
// Rebooting is managed by BootPrompt.cpp. // Rebooting is managed by BootPrompt.cpp.
BAlert* alert = new BAlert(B_TRANSLATE_SYSTEM_NAME("Quit Haiku"), BAlert* alert = new(std::nothrow) BAlert(
B_TRANSLATE_SYSTEM_NAME("Quit Haiku"),
B_TRANSLATE("Are you sure you want to close this window? This will " B_TRANSLATE("Are you sure you want to close this window? This will "
"restart your system!"), "restart your system!"),
B_TRANSLATE("Cancel"), B_TRANSLATE("Restart system"), NULL, B_TRANSLATE("Cancel"), B_TRANSLATE("Restart system"), NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT); B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->SetShortcut(0, B_ESCAPE); if (alert != NULL) {
alert->SetShortcut(0, B_ESCAPE);
if (alert->Go() == 0) { if (alert->Go() == 0) {
return false; return false;
}
} }
be_app->PostMessage(MSG_REBOOT_REQUESTED); be_app->PostMessage(MSG_REBOOT_REQUESTED);