 Chromium Code Reviews
 Chromium Code Reviews Issue 405083004:
  Removed potential memory leak in PasswordFormManager::OnRequestDone  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 405083004:
  Removed potential memory leak in PasswordFormManager::OnRequestDone  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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]; | 
| } |