From e2de726d7f986384aa0fd3892bd0737143aca1d9 Mon Sep 17 00:00:00 2001 From: Dana Fried Date: Thu, 17 Mar 2022 19:25:38 +0000 Subject: [PATCH] Avoid hard-crash in password bubble. It was evidently possible for the switch statement to fall through a NOTREACHED() and return a null pointer in some cases, in DCHECK we would be notified but in non-DCHECK it just crashes the browser. It is correct to detect the bad state in DCHECK mode but also we need to not hard-crash if we do not create a dialog. This is a spot fix for a larger issue and I'll be handing it off to the dialog's owner for further triage. (cherry picked from commit 2321589445a901c10d52311862a7088bd32d1379) Bug: 1305276 Change-Id: Ic19d680943a1dabc2bae6496c25a2ed381b3d950 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3522805 Commit-Queue: Dana Fried Auto-Submit: Dana Fried Reviewed-by: Mohamed Amir Yosef Commit-Queue: Mohamed Amir Yosef Cr-Original-Commit-Position: refs/heads/main@{#980812} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3533283 Bot-Commit: Rubber Stamper Cr-Commit-Position: refs/branch-heads/4896@{#641} Cr-Branched-From: 1f63ff4bc27570761b35ffbc7f938f6586f7bee8-refs/heads/main@{#972766} --- .../browser/ui/views/passwords/password_bubble_view_base.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chrome/browser/ui/views/passwords/password_bubble_view_base.cc b/chrome/browser/ui/views/passwords/password_bubble_view_base.cc index 257da6a773ea2..bbbd81b1db7a4 100644 --- a/chrome/browser/ui/views/passwords/password_bubble_view_base.cc +++ b/chrome/browser/ui/views/passwords/password_bubble_view_base.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ui/views/passwords/password_bubble_view_base.h" +#include "base/notreached.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" @@ -52,6 +53,11 @@ void PasswordBubbleViewBase::ShowBubble(content::WebContents* web_contents, CreateBubble(web_contents, anchor_view, reason); DCHECK(bubble); DCHECK_EQ(bubble, g_manage_passwords_bubble_); + // TODO(crbug.com/1305276): In non-DCHECK mode we could fall through here and + // hard-crash if we requested a bubble and were in the wrong state. In the + // meantime we will abort if we did not create a bubble. + if (!g_manage_passwords_bubble_) + return; g_manage_passwords_bubble_->SetHighlightedButton( button_provider->GetPageActionIconView(