Skip to content

Commit

Permalink
Avoid hard-crash in password bubble.
Browse files Browse the repository at this point in the history
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 2321589)

Bug: 1305276
Change-Id: Ic19d680943a1dabc2bae6496c25a2ed381b3d950
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3522805
Commit-Queue: Dana Fried <dfried@chromium.org>
Auto-Submit: Dana Fried <dfried@chromium.org>
Reviewed-by: Mohamed Amir Yosef <mamir@chromium.org>
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#980812}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3533283
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/4896@{#641}
Cr-Branched-From: 1f63ff4-refs/heads/main@{#972766}
  • Loading branch information
Dana Fried authored and Chromium LUCI CQ committed Mar 17, 2022
1 parent 80ee04e commit e2de726
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -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"
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit e2de726

Please sign in to comment.