summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-25 20:18:15 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-25 20:18:15 +0000
commit193320768adf7e97c371bf3dbcb514fdc8c8a285 (patch)
tree6d54efda949468b9efe9130e7bd5071b5ef6a16b /net
parent996a849b99aab436b9fcccd0bd7d2f4369ea92c1 (diff)
downloadchromium_src-193320768adf7e97c371bf3dbcb514fdc8c8a285.zip
chromium_src-193320768adf7e97c371bf3dbcb514fdc8c8a285.tar.gz
chromium_src-193320768adf7e97c371bf3dbcb514fdc8c8a285.tar.bz2
Fix invalid scoped_ptr_malloc assignment if NSSProfileFilterChromeOS::Init is called twice.
BUG=none R=rsleevi@chromium.org, sky@chromium.org Review URL: https://codereview.chromium.org/174673002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253241 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/cert/nss_profile_filter_chromeos.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/net/cert/nss_profile_filter_chromeos.cc b/net/cert/nss_profile_filter_chromeos.cc
index 5678426..e555750 100644
--- a/net/cert/nss_profile_filter_chromeos.cc
+++ b/net/cert/nss_profile_filter_chromeos.cc
@@ -60,8 +60,15 @@ NSSProfileFilterChromeOS& NSSProfileFilterChromeOS::operator=(
void NSSProfileFilterChromeOS::Init(crypto::ScopedPK11Slot public_slot,
crypto::ScopedPK11Slot private_slot) {
- public_slot_ = public_slot.Pass();
- private_slot_ = private_slot.Pass();
+ // crypto::ScopedPK11Slot actually holds a reference counted object.
+ // Because scoped_ptr<T> assignment is a no-op if it already points to
+ // the same pointer, a reference would be leaked because .Pass() does
+ // not release its reference, and the receiving object won't free
+ // its copy.
+ if (public_slot_.get() != public_slot.get())
+ public_slot_ = public_slot.Pass();
+ if (private_slot_.get() != private_slot.get())
+ private_slot_ = private_slot.Pass();
}
bool NSSProfileFilterChromeOS::IsModuleAllowed(PK11SlotInfo* slot) const {