diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-20 22:16:38 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-20 22:16:38 +0000 |
commit | a3ba3289219898411b3f3d9aea4a316a0bea19d7 (patch) | |
tree | f8c51e8c9ea86908f8611d359601292509a3f629 /net | |
parent | 084683940bef81aeeceb00db74f674422c831ff4 (diff) | |
download | chromium_src-a3ba3289219898411b3f3d9aea4a316a0bea19d7.zip chromium_src-a3ba3289219898411b3f3d9aea4a316a0bea19d7.tar.gz chromium_src-a3ba3289219898411b3f3d9aea4a316a0bea19d7.tar.bz2 |
Fix memory leak caused by bad reference counting. When the test server is
allocated it has a reference count of 0, so calling Release again, does not
free the memory. The fix is to use a scoped_refptr for both the return value
as well as for the local variable.
This failure case is triggered by the purify bot not having the test
certificate installed. We should also fix that so that we run more tests on
the purify bot. Testing this case is also interesting I guess :)
TBR=erikkay
Review URL: http://codereview.chromium.org/27013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10129 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/url_request/url_request_unittest.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h index 692ee9a..d880367 100644 --- a/net/url_request/url_request_unittest.h +++ b/net/url_request/url_request_unittest.h @@ -309,8 +309,8 @@ class BaseTestServer : public base::RefCounted<BaseTestServer> { bool success_; DISALLOW_COPY_AND_ASSIGN(SyncTestDelegate); }; - net::TestServerLauncher launcher_; + net::TestServerLauncher launcher_; std::string base_address_; }; @@ -324,15 +324,16 @@ class HTTPTestServer : public BaseTestServer { public: // Creates and returns a new HTTPTestServer. If |loop| is non-null, requests // are serviced on it, otherwise a new thread and message loop are created. - static HTTPTestServer* CreateServer(const std::wstring& document_root, - MessageLoop* loop) { - HTTPTestServer* test_server = new HTTPTestServer(); + static scoped_refptr<HTTPTestServer> CreateServer( + const std::wstring& document_root, + MessageLoop* loop) { + scoped_refptr<HTTPTestServer> test_server = new HTTPTestServer(); test_server->loop_ = loop; FilePath no_cert; FilePath docroot = FilePath::FromWStringHack(document_root); if (!test_server->Start(net::TestServerLauncher::ProtoHTTP, - kDefaultHostName, kHTTPDefaultPort, docroot, no_cert)) { - test_server->Release(); + kDefaultHostName, kHTTPDefaultPort, + docroot, no_cert)) { return NULL; } return test_server; |