summaryrefslogtreecommitdiffstats
path: root/sandbox/win/src/win_utils.cc
diff options
context:
space:
mode:
authorkcarattini <kcarattini@chromium.org>2015-04-07 00:00:14 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-07 07:00:49 +0000
commit2a02e87219ffae9473c3bb2fcdc5c31adc1dfc43 (patch)
tree7483bd9cb86f0afa0f0f72c034cd3eda9e9c2b3f /sandbox/win/src/win_utils.cc
parent72707297f6955def13c905ce0ff5acfe46fd011c (diff)
downloadchromium_src-2a02e87219ffae9473c3bb2fcdc5c31adc1dfc43.zip
chromium_src-2a02e87219ffae9473c3bb2fcdc5c31adc1dfc43.tar.gz
chromium_src-2a02e87219ffae9473c3bb2fcdc5c31adc1dfc43.tar.bz2
Revert of Fix scoped_ptr free to use delete [] instead of delete. (patchset #1 id:1 of https://codereview.chromium.org/1055433003/)
Reason for revert: It looks like this broke the following test on XP Tests (1): sbox_unittests WinUtils.SameObject Example output: WinUtils.SameObject (run #1): [ RUN ] WinUtils.SameObject c:\b\build\slave\win_builder\build\src\sandbox\win\src\win_utils_unittest.cc(78): error: Value of: SameObject(file.Get(), file_name_nt1.c_str()) Actual: false Expected: true c:\b\build\slave\win_builder\build\src\sandbox\win\src\win_utils_unittest.cc(79): error: Value of: SameObject(file.Get(), file_name_nt2.c_str()) Actual: false Expected: true [ FAILED ] WinUtils.SameObject (16 ms) Original issue's description: > Fix scoped_ptr free to use delete [] instead of delete. > > BUG=101717 > > Committed: https://crrev.com/7804b679be3af7e24578394af0a85ba1249344a9 > Cr-Commit-Position: refs/heads/master@{#324013} TBR=cpu@chromium.org,wfh@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=101717 Review URL: https://codereview.chromium.org/1065833002 Cr-Commit-Position: refs/heads/master@{#324016}
Diffstat (limited to 'sandbox/win/src/win_utils.cc')
-rw-r--r--sandbox/win/src/win_utils.cc21
1 files changed, 11 insertions, 10 deletions
diff --git a/sandbox/win/src/win_utils.cc b/sandbox/win/src/win_utils.cc
index 1cf1b09..d2b507d 100644
--- a/sandbox/win/src/win_utils.cc
+++ b/sandbox/win/src/win_utils.cc
@@ -351,21 +351,22 @@ bool GetPathFromHandle(HANDLE handle, base::string16* path) {
NtQueryObjectFunction NtQueryObject = NULL;
ResolveNTFunctionPtr("NtQueryObject", &NtQueryObject);
- OBJECT_NAME_INFORMATION* name = NULL;
- ULONG size = 0;
+ OBJECT_NAME_INFORMATION initial_buffer;
+ OBJECT_NAME_INFORMATION* name = &initial_buffer;
+ ULONG size = sizeof(initial_buffer);
// Query the name information a first time to get the size of the name.
NTSTATUS status = NtQueryObject(handle, ObjectNameInformation, name, size,
&size);
- if (!size)
- return false;
-
- scoped_ptr<BYTE[]> name_ptr(new BYTE[size]);
- name = reinterpret_cast<OBJECT_NAME_INFORMATION*>(name_ptr.get());
+ scoped_ptr<OBJECT_NAME_INFORMATION> name_ptr;
+ if (size) {
+ name = reinterpret_cast<OBJECT_NAME_INFORMATION*>(new BYTE[size]);
+ name_ptr.reset(name);
- // Query the name information a second time to get the name of the
- // object referenced by the handle.
- status = NtQueryObject(handle, ObjectNameInformation, name, size, &size);
+ // Query the name information a second time to get the name of the
+ // object referenced by the handle.
+ status = NtQueryObject(handle, ObjectNameInformation, name, size, &size);
+ }
if (STATUS_SUCCESS != status)
return false;