Commit fe9d0eac authored by Maxim Kolosovskiy's avatar Maxim Kolosovskiy Committed by Commit Bot

[Password Generation] Hot fix for a crash in PasswordGenerationAgent

|(element.Form() == generation_element_.Form())| in PasswordGenerationAgent::TextDidChangeInTextField causes a crash. |element| or |generation_element_| is null.

Probable reason: That code assumes that |generation_element_| must be non-null if |password_is_generated_| is true. But in PasswordGenerationAgent::DidCommitProvisionalLoad, |generation_element_| is cleared while |password_is_generated_| stays the same. So, it is possible that |generation_element_| is null while |password_is_generated_| is true.

TBR=dvadym@, vasilii@, ioanap@
Bug: 879713

Change-Id: I4b8a42ab8aebb1474f7a3b57c9fa63ab15dcd610
Reviewed-on: https://chromium-review.googlesource.com/1200642
Commit-Queue: Maxim Kolosovskiy <kolos@chromium.org>
Reviewed-by: default avatarMaxim Kolosovskiy <kolos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588277}
parent 52510d6e
...@@ -211,6 +211,7 @@ void PasswordGenerationAgent::DidCommitProvisionalLoad( ...@@ -211,6 +211,7 @@ void PasswordGenerationAgent::DidCommitProvisionalLoad(
bool /*is_new_navigation*/, bool is_same_document_navigation) { bool /*is_new_navigation*/, bool is_same_document_navigation) {
if (is_same_document_navigation) if (is_same_document_navigation)
return; return;
password_is_generated_ = false;
generation_element_.Reset(); generation_element_.Reset();
last_focused_password_element_.Reset(); last_focused_password_element_.Reset();
} }
...@@ -602,7 +603,12 @@ bool PasswordGenerationAgent::TextDidChangeInTextField( ...@@ -602,7 +603,12 @@ bool PasswordGenerationAgent::TextDidChangeInTextField(
const WebInputElement& element) { const WebInputElement& element) {
if (element != generation_element_) { if (element != generation_element_) {
// Presave the username if it has been changed. // Presave the username if it has been changed.
if (password_is_generated_ && // TODO(crbug.com/879713): investigate why the following DCHECKs can be
// triggered.
DCHECK(!element.IsNull());
DCHECK(!password_is_generated_ || !generation_element_.IsNull());
if (password_is_generated_ && !element.IsNull() &&
!generation_element_.IsNull() &&
(element.Form() == generation_element_.Form())) { (element.Form() == generation_element_.Form())) {
std::unique_ptr<PasswordForm> presaved_form( std::unique_ptr<PasswordForm> presaved_form(
CreatePasswordFormToPresave()); CreatePasswordFormToPresave());
......
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