Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Unified Diff: components/password_manager/core/browser/password_form_manager.cc

Issue 405083004: Removed potential memory leak in PasswordFormManager::OnRequestDone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Coding style Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/password_manager/core/browser/password_form_manager.cc
diff --git a/components/password_manager/core/browser/password_form_manager.cc b/components/password_manager/core/browser/password_form_manager.cc
index 185c11ac3a6e86b75672a3a4e1cf995a4a955a43..88eef047ab512171494578307f1d5a8c3f9929da 100644
--- a/components/password_manager/core/browser/password_form_manager.cc
+++ b/components/password_manager/core/browser/password_form_manager.cc
@@ -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();
Garrett Casto 2014/07/22 21:06:44 Was this intentional? I'm not sure why you don't w
Lukasz Jagielski 2014/07/23 14:52:18 I removed this, because STLDeleteValues does that
preferred_match_ = NULL; // Don't delete, its owned by best_matches_.
best_matches_[logins_result[i]->username_value] = logins_result[i];
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698