Commit 0cc68a24 authored by ljagielski@opera.com's avatar ljagielski@opera.com

Removed potential memory leak in PasswordFormManager::OnRequestDone

BUG=395190

Review URL: https://codereview.chromium.org/405083004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285140 0039d316-1c4b-4281-b951-d872f2087c98
parent ffdb373a
......@@ -390,13 +390,18 @@ void PasswordFormManager::OnRequestDone(
continue;
}
if (current_score == best_score) {
PasswordForm* old_form = best_matches_[logins_result[i]->username_value];
if (old_form) {
if (preferred_match_ == old_form)
preferred_match_ = NULL;
delete old_form;
}
best_matches_[logins_result[i]->username_value] = logins_result[i];
} else if (current_score > best_score) {
best_score = current_score;
// This new login has a better score than all those up to this point
// Note 'this' owns all the PasswordForms in best_matches_.
STLDeleteValues(&best_matches_);
best_matches_.clear();
preferred_match_ = NULL; // Don't delete, its owned by best_matches_.
best_matches_[logins_result[i]->username_value] = logins_result[i];
}
......
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