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

Unified Diff: base/process/process_metrics_win.cc

Issue 2779413002: Duplicate process handle in process_metrics_win.cc (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/process_metrics_win.cc
diff --git a/base/process/process_metrics_win.cc b/base/process/process_metrics_win.cc
index 24760213f8d0695f1eff3d3c23be0f0e42598a7b..9ef38d5f32e604e31a44f98cfb60cfd1081567fb 100644
--- a/base/process/process_metrics_win.cc
+++ b/base/process/process_metrics_win.cc
@@ -31,7 +31,10 @@ typedef NTSTATUS(WINAPI* NTQUERYSYSTEMINFORMATION)(
} // namespace
-ProcessMetrics::~ProcessMetrics() { }
+ProcessMetrics::~ProcessMetrics() {
+ if (process_)
+ ::CloseHandle(process_);
brucedawson 2017/03/30 23:09:46 Shouldn't this use a handle wrapper class rather t
stanisc 2017/03/30 23:24:34 It should, but process_ field is defined in the he
+}
// static
std::unique_ptr<ProcessMetrics> ProcessMetrics::CreateProcessMetrics(
@@ -319,9 +322,16 @@ bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const {
}
ProcessMetrics::ProcessMetrics(ProcessHandle process)
- : process_(process),
+ : process_(nullptr),
processor_count_(SysInfo::NumberOfProcessors()),
- last_system_time_(0) {}
+ last_system_time_(0) {
+ if (process) {
+ BOOL result =
+ ::DuplicateHandle(::GetCurrentProcess(), process, ::GetCurrentProcess(),
+ &process_, PROCESS_QUERY_INFORMATION, FALSE, 0);
+ DCHECK(result);
+ }
+}
size_t GetSystemCommitCharge() {
// Get the System Page Size.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698