diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-12 19:39:55 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-12 19:39:55 +0000 |
commit | d92a7e670753fa0a24e592acf412d752e0ae6cd8 (patch) | |
tree | a547299764a7846ab523038575790e6f6ec242f9 /sandbox | |
parent | 73097564b57bad21efbb72e49a0edf0d13e9c249 (diff) | |
download | chromium_src-d92a7e670753fa0a24e592acf412d752e0ae6cd8.zip chromium_src-d92a7e670753fa0a24e592acf412d752e0ae6cd8.tar.gz chromium_src-d92a7e670753fa0a24e592acf412d752e0ae6cd8.tar.bz2 |
Fix memory dealocatiom mismatch by using scoped_ptr_malloc
- Flagged by almost all tools
BUG=101717
TEST= sandbox tests in the waterfall are green.
Review URL: http://codereview.chromium.org/9107029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117476 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/src/acl.cc | 12 | ||||
-rw-r--r-- | sandbox/src/acl.h | 5 |
2 files changed, 9 insertions, 8 deletions
diff --git a/sandbox/src/acl.cc b/sandbox/src/acl.cc index 9e7111d..4869bb0 100644 --- a/sandbox/src/acl.cc +++ b/sandbox/src/acl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -12,7 +12,7 @@ namespace sandbox { bool GetDefaultDacl(HANDLE token, - scoped_ptr<TOKEN_DEFAULT_DACL>* default_dacl) { + scoped_ptr_malloc<TOKEN_DEFAULT_DACL>* default_dacl) { if (token == NULL) return false; @@ -26,7 +26,7 @@ bool GetDefaultDacl(HANDLE token, } TOKEN_DEFAULT_DACL* acl = - reinterpret_cast<TOKEN_DEFAULT_DACL*>(new char[length]); + reinterpret_cast<TOKEN_DEFAULT_DACL*>(malloc(length)); default_dacl->reset(acl); if (!::GetTokenInformation(token, TokenDefaultDacl, default_dacl->get(), @@ -59,7 +59,7 @@ bool AddSidToDefaultDacl(HANDLE token, const Sid& sid, ACCESS_MASK access) { if (token == NULL) return false; - scoped_ptr<TOKEN_DEFAULT_DACL> default_dacl; + scoped_ptr_malloc<TOKEN_DEFAULT_DACL> default_dacl; if (!GetDefaultDacl(token, &default_dacl)) return false; @@ -78,9 +78,9 @@ bool AddSidToDefaultDacl(HANDLE token, const Sid& sid, ACCESS_MASK access) { bool AddUserSidToDefaultDacl(HANDLE token, ACCESS_MASK access) { DWORD size = sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE; - TOKEN_USER* token_user = reinterpret_cast<TOKEN_USER*>(new BYTE[size]); + TOKEN_USER* token_user = reinterpret_cast<TOKEN_USER*>(malloc(size)); - scoped_ptr<TOKEN_USER> token_user_ptr(token_user); + scoped_ptr_malloc<TOKEN_USER> token_user_ptr(token_user); if (!::GetTokenInformation(token, TokenUser, token_user, size, &size)) return false; diff --git a/sandbox/src/acl.h b/sandbox/src/acl.h index 0d8dc49..d452011 100644 --- a/sandbox/src/acl.h +++ b/sandbox/src/acl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -13,7 +13,8 @@ namespace sandbox { // Returns the default dacl from the token passed in. -bool GetDefaultDacl(HANDLE token, scoped_ptr<TOKEN_DEFAULT_DACL>* default_dacl); +bool GetDefaultDacl(HANDLE token, + scoped_ptr_malloc<TOKEN_DEFAULT_DACL>* default_dacl); // Appends an ACE represented by |sid| and |access| to |old_dacl|. If the // function succeeds, new_dacl contains the new dacl and must be freed using |