Chromium Code Reviews| Index: sandbox/win/src/sandbox_policy_base.cc |
| diff --git a/sandbox/win/src/sandbox_policy_base.cc b/sandbox/win/src/sandbox_policy_base.cc |
| index 6df2cb3d3819d33c2e742efdc441192de16ca996..482172cb75be9bcb961c9ba1d6d680edd75fb4f0 100644 |
| --- a/sandbox/win/src/sandbox_policy_base.cc |
| +++ b/sandbox/win/src/sandbox_policy_base.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/basictypes.h" |
| #include "base/callback.h" |
| #include "base/logging.h" |
| +#include "base/stl_util.h" |
| #include "base/strings/stringprintf.h" |
| #include "base/win/windows_version.h" |
| #include "sandbox/win/src/app_container.h" |
| @@ -466,33 +467,26 @@ ResultCode PolicyBase::AddKernelObjectToClose(const base::char16* handle_type, |
| void* PolicyBase::AddHandleToShare(HANDLE handle) { |
| if (base::win::GetVersion() < base::win::VERSION_VISTA) |
| - return NULL; |
| + return nullptr; |
| if (!handle) |
| - return NULL; |
| + return nullptr; |
| - HANDLE duped_handle = NULL; |
| - ::DuplicateHandle(::GetCurrentProcess(), |
| - handle, |
| - ::GetCurrentProcess(), |
| - &duped_handle, |
| - 0, |
| - TRUE, |
| - DUPLICATE_SAME_ACCESS); |
| - DCHECK(duped_handle); |
| - handles_to_share_.push_back(duped_handle); |
| + HANDLE duped_handle = nullptr; |
| + if (!::DuplicateHandle(::GetCurrentProcess(), handle, ::GetCurrentProcess(), |
| + &duped_handle, 0, TRUE, DUPLICATE_SAME_ACCESS)) { |
| + return nullptr; |
| + } |
| + handles_to_share_.push_back(new base::win::ScopedHandle(duped_handle)); |
|
Will Harris
2015/07/10 18:05:02
this is a behavior change, previously we'd push a
rvargas (doing something else)
2015/07/10 18:26:45
Correct, but judging by the (insufficient) dcheck,
|
| return duped_handle; |
| } |
| -HandleList PolicyBase::GetHandlesBeingShared() { |
| +const HandleList& PolicyBase::GetHandlesBeingShared() { |
| return handles_to_share_; |
| } |
| void PolicyBase::ClearSharedHandles() { |
| - for (auto handle : handles_to_share_) { |
| - ::CloseHandle(handle); |
| - } |
| - handles_to_share_.clear(); |
| + STLDeleteElements(&handles_to_share_); |
| } |
| // When an IPC is ready in any of the targets we get called. We manage an array |