From c12236c0ad94b6bc8c0e33370cec35d4eeb35718 Mon Sep 17 00:00:00 2001 From: "noelutz@google.com" Date: Fri, 22 Jul 2011 15:51:09 +0000 Subject: Fix memory leaks in client_side_detection_host_unittest. SAME as http://codereview.chromium.org/7473002/. BUG=89890 TEST=Ran unittest with valgrind. Review URL: http://codereview.chromium.org/7484031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93642 0039d316-1c4b-4281-b951-d872f2087c98 --- .../safe_browsing/client_side_detection_host_unittest.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'chrome/browser/safe_browsing') diff --git a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc index d9e0a82..4584e93 100644 --- a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc +++ b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc @@ -67,7 +67,9 @@ ACTION(QuitUIMessageLoop) { ACTION_TEMPLATE(InvokeCallbackArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_2_VALUE_PARAMS(p0, p1)) { - return ::std::tr1::get(args)->Run(p0, p1); + ::std::tr1::get(args)->Run(p0, p1); + // This is an old callback, so it needs to be deleted explicitly. + delete ::std::tr1::get(args); } class MockClientSideDetectionService : public ClientSideDetectionService { @@ -284,7 +286,8 @@ TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneNotPhishing) { verdict.set_is_phishing(true); EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _)) - .WillOnce(InvokeCallbackArgument<2>(true, &verdict)); + .WillOnce(DoAll(DeleteArg<1>(), + InvokeCallbackArgument<2>(true, &verdict))); EXPECT_CALL(*csd_service_, SendClientReportPhishingRequest( Pointee(PartiallyEqualVerdict(verdict)), _)) @@ -316,7 +319,8 @@ TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneDisabled) { verdict.set_is_phishing(true); EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _)) - .WillOnce(InvokeCallbackArgument<2>(true, &verdict)); + .WillOnce(DoAll(DeleteArg<1>(), + InvokeCallbackArgument<2>(true, &verdict))); EXPECT_CALL(*csd_service_, SendClientReportPhishingRequest( Pointee(PartiallyEqualVerdict(verdict)), _)) @@ -349,7 +353,8 @@ TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneShowInterstitial) { verdict.set_is_phishing(true); EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _)) - .WillOnce(InvokeCallbackArgument<2>(true, &verdict)); + .WillOnce(DoAll(DeleteArg<1>(), + InvokeCallbackArgument<2>(true, &verdict))); EXPECT_CALL(*csd_service_, SendClientReportPhishingRequest( Pointee(PartiallyEqualVerdict(verdict)), _)) @@ -409,7 +414,8 @@ TEST_F(ClientSideDetectionHostTest, OnPhishingDetectionDoneMultiplePings) { verdict.set_is_phishing(true); EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _, _)) - .WillOnce(InvokeCallbackArgument<2>(true, &verdict)); + .WillOnce(DoAll(DeleteArg<1>(), + InvokeCallbackArgument<2>(true, &verdict))); EXPECT_CALL(*csd_service_, SendClientReportPhishingRequest( Pointee(PartiallyEqualVerdict(verdict)), _)) -- cgit v1.1