summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorgeorgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-22 18:15:03 +0000
committergeorgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-22 18:15:03 +0000
commit42f80df44247451f45b087237136560e06c3bb5f (patch)
tree1898c3755dca15d99f81d83779f6ee1b62e890bd /chrome
parent0ba5b7b94677f67fd85ca98b18471359194d7052 (diff)
downloadchromium_src-42f80df44247451f45b087237136560e06c3bb5f.zip
chromium_src-42f80df44247451f45b087237136560e06c3bb5f.tar.gz
chromium_src-42f80df44247451f45b087237136560e06c3bb5f.tar.bz2
Fix memory leak for autofil profiles and credit cards.
BUG=42185 TEST=In the bug. Review URL: http://codereview.chromium.org/1732004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45330 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/webdata/web_data_service.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc
index f0ba6fa..8436aa4 100644
--- a/chrome/browser/webdata/web_data_service.cc
+++ b/chrome/browser/webdata/web_data_service.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/webdata/web_data_service.h"
#include "base/message_loop.h"
+#include "base/stl_util-inl.h"
#include "base/task.h"
#include "base/thread.h"
#include "chrome/browser/autofill/autofill_profile.h"
@@ -253,6 +254,25 @@ void WebDataService::RequestCompleted(Handle h) {
if (!request->IsCancelled() && (consumer = request->GetConsumer())) {
consumer->OnWebDataServiceRequestDone(request->GetHandle(),
request->GetResult());
+ } else {
+ // Nobody is taken ownership of the result, either because it is canceled
+ // or there is no consumer. Destroy results that require special handling.
+ WDTypedResult const *result = request->GetResult();
+ if (result) {
+ if (result->GetType() == AUTOFILL_PROFILES_RESULT) {
+ const WDResult<std::vector<AutoFillProfile*> >* r =
+ static_cast<const WDResult<std::vector<AutoFillProfile*> >*>(
+ result);
+ std::vector<AutoFillProfile*> profiles = r->GetValue();
+ STLDeleteElements(&profiles);
+ } else if (result->GetType() == AUTOFILL_CREDITCARDS_RESULT) {
+ const WDResult<std::vector<CreditCard*> >* r =
+ static_cast<const WDResult<std::vector<CreditCard*> >*>(result);
+
+ std::vector<CreditCard*> credit_cards = r->GetValue();
+ STLDeleteElements(&credit_cards);
+ }
+ }
}
}