Skip to content

Commit

Permalink
Revert of Fix scoped_ptr free to use delete [] instead of delete. (pa…
Browse files Browse the repository at this point in the history
…tchset chromium#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 chromium#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}
  • Loading branch information
kcarattini authored and Commit bot committed Apr 7, 2015
1 parent 7270729 commit 2a02e87
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions sandbox/win/src/win_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2a02e87

Please sign in to comment.