From 655051daaef6ec771e01887c4e0c7a1ad7f5702a Mon Sep 17 00:00:00 2001 From: "tim@chromium.org" Date: Fri, 2 Apr 2010 02:31:10 +0000 Subject: Fix AutoFillProfile leaks in WebDataService. TBR=akalin Review URL: http://codereview.chromium.org/1569016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43438 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/webdata/web_data_service.cc | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'chrome/browser/webdata') diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc index 1874564..f0ba6fa 100644 --- a/chrome/browser/webdata/web_data_service.cc +++ b/chrome/browser/webdata/web_data_service.cc @@ -806,10 +806,11 @@ void WebDataService::UpdateAutoFillProfileImpl( // The AUTOFILL_PROFILE_CHANGED contract for an update requires that we // send along the label of the un-updated profile, to detect label // changes separately. So first, we query for the existing profile. - AutoFillProfile* old_profile = NULL; - if (!db_->GetAutoFillProfileForID(profile.unique_id(), &old_profile)) + AutoFillProfile* old_profile_ptr = NULL; + if (!db_->GetAutoFillProfileForID(profile.unique_id(), &old_profile_ptr)) NOTREACHED(); - if (old_profile) { + if (old_profile_ptr) { + scoped_ptr old_profile(old_profile_ptr); if (!db_->UpdateAutoFillProfile(profile)) NOTREACHED(); ScheduleCommit(); @@ -831,11 +832,12 @@ void WebDataService::RemoveAutoFillProfileImpl( InitializeDatabaseIfNecessary(); if (db_ && !request->IsCancelled()) { int profile_id = request->GetArgument(); - AutoFillProfile* dead_profile = NULL; - if (!db_->GetAutoFillProfileForID(profile_id, &dead_profile)) + AutoFillProfile* profile = NULL; + if (!db_->GetAutoFillProfileForID(profile_id, &profile)) NOTREACHED(); - if (dead_profile) { + if (profile) { + scoped_ptr dead_profile(profile); if (!db_->RemoveAutoFillProfile(profile_id)) NOTREACHED(); ScheduleCommit(); @@ -907,14 +909,17 @@ void WebDataService::RemoveCreditCardImpl( InitializeDatabaseIfNecessary(); if (db_ && !request->IsCancelled()) { int creditcard_id = request->GetArgument(); - CreditCard* dead_card = NULL; - if (!db_->GetCreditCardForID(creditcard_id, &dead_card)) + CreditCard* dead_card_ptr = NULL; + if (!db_->GetCreditCardForID(creditcard_id, &dead_card_ptr)) NOTREACHED(); + + scoped_ptr dead_card(dead_card_ptr); if (!db_->RemoveCreditCard(creditcard_id)) NOTREACHED(); + ScheduleCommit(); - if (dead_card) { + if (dead_card.get()) { AutofillCreditCardChange change(AutofillCreditCardChange::REMOVE, dead_card->Label(), NULL); NotificationService::current()->Notify( -- cgit v1.1