diff options
author | asanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-13 17:36:32 +0000 |
---|---|---|
committer | asanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-13 17:36:32 +0000 |
commit | 8b262354e6f28e2f9580f924b5f9cf9d580eb3c2 (patch) | |
tree | 3423bc66192d44ff74368d69059277a24228005d /net | |
parent | db09c194c77cb6e1a504986e3d24888fdda9b006 (diff) | |
download | chromium_src-8b262354e6f28e2f9580f924b5f9cf9d580eb3c2.zip chromium_src-8b262354e6f28e2f9580f924b5f9cf9d580eb3c2.tar.gz chromium_src-8b262354e6f28e2f9580f924b5f9cf9d580eb3c2.tar.bz2 |
Don't leak SSPILibraryDefault objects
BUG=74413
TEST=Dr. Memory.
Review URL: http://codereview.chromium.org/7864005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100930 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_auth_handler_ntlm.h | 14 | ||||
-rw-r--r-- | net/http/http_auth_handler_ntlm_win.cc | 6 |
2 files changed, 9 insertions, 11 deletions
diff --git a/net/http/http_auth_handler_ntlm.h b/net/http/http_auth_handler_ntlm.h index 828e512..d0285dc 100644 --- a/net/http/http_auth_handler_ntlm.h +++ b/net/http/http_auth_handler_ntlm.h @@ -50,14 +50,12 @@ class NET_EXPORT_PRIVATE HttpAuthHandlerNTLM : public HttpAuthHandler { const BoundNetLog& net_log, scoped_ptr<HttpAuthHandler>* handler); #if defined(NTLM_SSPI) - // Set the SSPILibrary to use. Typically the only callers which need to - // use this are unit tests which pass in a mocked-out version of the - // SSPI library. - // The caller is responsible for managing the lifetime of |*sspi_library|, - // and the lifetime must exceed that of this Factory object and all - // HttpAuthHandler's that this Factory object creates. + // Set the SSPILibrary to use. Typically the only callers which need to use + // this are unit tests which pass in a mocked-out version of the SSPI + // library. After the call |sspi_library| will be owned by this Factory and + // will be destroyed when the Factory is destroyed. void set_sspi_library(SSPILibrary* sspi_library) { - sspi_library_ = sspi_library; + sspi_library_.reset(sspi_library); } #endif // defined(NTLM_SSPI) private: @@ -65,7 +63,7 @@ class NET_EXPORT_PRIVATE HttpAuthHandlerNTLM : public HttpAuthHandler { ULONG max_token_length_; bool first_creation_; bool is_unsupported_; - SSPILibrary* sspi_library_; + scoped_ptr<SSPILibrary> sspi_library_; #endif // defined(NTLM_SSPI) }; diff --git a/net/http/http_auth_handler_ntlm_win.cc b/net/http/http_auth_handler_ntlm_win.cc index 684f29d..d624f12 100644 --- a/net/http/http_auth_handler_ntlm_win.cc +++ b/net/http/http_auth_handler_ntlm_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -63,7 +63,7 @@ int HttpAuthHandlerNTLM::Factory::CreateAuthHandler( if (is_unsupported_ || reason == CREATE_PREEMPTIVE) return ERR_UNSUPPORTED_AUTH_SCHEME; if (max_token_length_ == 0) { - int rv = DetermineMaxTokenLength(sspi_library_, NTLMSP_NAME, + int rv = DetermineMaxTokenLength(sspi_library_.get(), NTLMSP_NAME, &max_token_length_); if (rv == ERR_UNSUPPORTED_AUTH_SCHEME) is_unsupported_ = true; @@ -73,7 +73,7 @@ int HttpAuthHandlerNTLM::Factory::CreateAuthHandler( // TODO(cbentzel): Move towards model of parsing in the factory // method and only constructing when valid. scoped_ptr<HttpAuthHandler> tmp_handler( - new HttpAuthHandlerNTLM(sspi_library_, max_token_length_, + new HttpAuthHandlerNTLM(sspi_library_.get(), max_token_length_, url_security_manager())); if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) return ERR_INVALID_RESPONSE; |