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

Side by Side Diff: sandbox/win/tests/common/controller.cc

Issue 2316333003: Fix sandbox::PolicyBase leak (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: switch back to start with refcount 1 Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « sandbox/win/tests/common/controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sandbox/win/tests/common/controller.h" 5 #include "sandbox/win/tests/common/controller.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/process/process.h" 10 #include "base/process/process.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 if (!policy_) 129 if (!policy_)
130 return; 130 return;
131 131
132 policy_->SetJobLevel(job_level, 0); 132 policy_->SetJobLevel(job_level, 0);
133 policy_->SetTokenLevel(startup_token, main_token); 133 policy_->SetTokenLevel(startup_token, main_token);
134 134
135 is_init_ = true; 135 is_init_ = true;
136 } 136 }
137 137
138 TargetPolicy* TestRunner::GetPolicy() { 138 TargetPolicy* TestRunner::GetPolicy() {
139 return policy_; 139 return policy_.get();
140 } 140 }
141 141
142 TestRunner::~TestRunner() { 142 TestRunner::~TestRunner() {
143 if (target_process_.IsValid() && kill_on_destruction_) 143 if (target_process_.IsValid() && kill_on_destruction_)
144 ::TerminateProcess(target_process_.Get(), 0); 144 ::TerminateProcess(target_process_.Get(), 0);
145
146 if (policy_)
147 policy_->Release();
148 } 145 }
149 146
150 bool TestRunner::AddRule(TargetPolicy::SubSystem subsystem, 147 bool TestRunner::AddRule(TargetPolicy::SubSystem subsystem,
151 TargetPolicy::Semantics semantics, 148 TargetPolicy::Semantics semantics,
152 const wchar_t* pattern) { 149 const wchar_t* pattern) {
153 if (!is_init_) 150 if (!is_init_)
154 return false; 151 return false;
155 152
156 return (SBOX_ALL_OK == policy_->AddRule(subsystem, semantics, pattern)); 153 return (SBOX_ALL_OK == policy_->AddRule(subsystem, semantics, pattern));
157 } 154 }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 365
369 target->LowerToken(); 366 target->LowerToken();
370 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) { 367 } else if (0 != _wcsicmp(argv[1], L"-child-no-sandbox")) {
371 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 368 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
372 } 369 }
373 370
374 return command(argc - 4, argv + 4); 371 return command(argc - 4, argv + 4);
375 } 372 }
376 373
377 } // namespace sandbox 374 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/tests/common/controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698