diff --git a/components/password_manager/core/browser/password_manual_fallback_flow.cc b/components/password_manager/core/browser/password_manual_fallback_flow.cc index 8e847531b32e9..cc0dbd9a0c3bc 100644 --- a/components/password_manager/core/browser/password_manual_fallback_flow.cc +++ b/components/password_manager/core/browser/password_manual_fallback_flow.cc @@ -266,6 +266,12 @@ void PasswordManualFallbackFlow::DidAcceptSuggestion( "PasswordManager.ManualFallback.AcceptedSuggestion.FromRootPopup", metadata.sub_popup_level == 0); + // On macOS without biometrics, the kPasswordEntry / kFillPassword / + // kViewPasswordDetails branches below can synchronously enter + // AuthorizationCopyRights, which pumps a nested CFRunLoop on the UI thread. + // The page (and therefore `this`) can be torn down inside that loop, so + // guard the trailing `autofill_client_` dereference. + auto weak_this = weak_ptr_factory_.GetWeakPtr(); switch (suggestion.type) { case autofill::SuggestionType::kPasswordEntry: { if (!form) { @@ -339,6 +345,9 @@ void PasswordManualFallbackFlow::DidAcceptSuggestion( // Other suggestion types are not supported. NOTREACHED(); } + if (!weak_this) { + return; + } autofill_client_->HideAutofillSuggestions( autofill::SuggestionHidingReason::kAcceptSuggestion); }