summaryrefslogtreecommitdiffstats
path: root/base/win_util.cc
diff options
context:
space:
mode:
authortimurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 15:25:04 +0000
committertimurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 15:25:04 +0000
commit9cbe3506d140cc846f7363a5b64f6b1e5b624d6c (patch)
treeae4219c463d63071ece7edee966739b262748cfb /base/win_util.cc
parent9bbb611a8a014e38cd9c0fed4ef41af989816333 (diff)
downloadchromium_src-9cbe3506d140cc846f7363a5b64f6b1e5b624d6c.zip
chromium_src-9cbe3506d140cc846f7363a5b64f6b1e5b624d6c.tar.gz
chromium_src-9cbe3506d140cc846f7363a5b64f6b1e5b624d6c.tar.bz2
Fixing scoped_ptr misusage in base/win_util.cc
BUG=24266 This patch was originally created by Alexander Potapenko (cc'ed) as http://codereview.chromium.org/264013 Review URL: http://codereview.chromium.org/262023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28537 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/win_util.cc')
-rw-r--r--base/win_util.cc17
1 files changed, 10 insertions, 7 deletions
diff --git a/base/win_util.cc b/base/win_util.cc
index 4fa1df0..e66dc1c 100644
--- a/base/win_util.cc
+++ b/base/win_util.cc
@@ -114,8 +114,9 @@ bool AddAccessToKernelObject(HANDLE handle, WELL_KNOWN_SID_TYPE known_sid,
}
DWORD size = sizeof(TOKEN_USER) + size_sid;
- TOKEN_USER* token_user = reinterpret_cast<TOKEN_USER*>(new BYTE[size]);
- scoped_ptr<TOKEN_USER> token_user_ptr(token_user);
+ scoped_array<BYTE> token_user_bytes(new BYTE[size]);
+ TOKEN_USER* token_user =
+ reinterpret_cast<TOKEN_USER*>(token_user_bytes.get());
BOOL ret = GetTokenInformation(token, TokenUser, token_user, size, &size);
CloseHandle(token);
@@ -168,9 +169,10 @@ bool GetUserSidString(std::wstring* user_sid) {
ScopedHandle token_scoped(token);
DWORD size = sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE;
- scoped_ptr<TOKEN_USER> user(reinterpret_cast<TOKEN_USER*>(new BYTE[size]));
+ scoped_array<BYTE> user_bytes(new BYTE[size]);
+ TOKEN_USER* user = reinterpret_cast<TOKEN_USER*>(user_bytes.get());
- if (!::GetTokenInformation(token, TokenUser, user.get(), size, &size))
+ if (!::GetTokenInformation(token, TokenUser, user, size, &size))
return false;
if (!user->User.Sid)
@@ -202,10 +204,11 @@ bool GetLogonSessionOnlyDACL(SECURITY_DESCRIPTOR** security_descriptor) {
return false;
// Get the data.
- scoped_ptr<TOKEN_GROUPS> token_groups;
- token_groups.reset(reinterpret_cast<TOKEN_GROUPS*>(new char[size]));
+ scoped_array<char> token_groups_chars(new char[size]);
+ TOKEN_GROUPS* token_groups =
+ reinterpret_cast<TOKEN_GROUPS*>(token_groups_chars.get());
- if (!GetTokenInformation(token, TokenGroups, token_groups.get(), size, &size))
+ if (!GetTokenInformation(token, TokenGroups, token_groups, size, &size))
return false;
// Look for the logon sid.