Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Unified Diff: sandbox/win/src/sandbox_policy_base.cc

Issue 1229163002: Sandbox: Remove raw handles from PolicyBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/win/src/sandbox_policy_base.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « sandbox/win/src/sandbox_policy_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698