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

Unified Diff: remoting/host/wts_session_process_launcher_win.cc

Issue 9700038: ScopedProcessInformation protects against process/thread handle leaks from CreateProcess calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add tests for new functions. Created 8 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
Index: remoting/host/wts_session_process_launcher_win.cc
diff --git a/remoting/host/wts_session_process_launcher_win.cc b/remoting/host/wts_session_process_launcher_win.cc
index 45d81cf7b2ca2a5826097dc0c7d93344cf48b3c0..c19bc17b715c301c71dde3720f794363c6774251 100644
--- a/remoting/host/wts_session_process_launcher_win.cc
+++ b/remoting/host/wts_session_process_launcher_win.cc
@@ -19,6 +19,7 @@
#include "base/threading/thread.h"
#include "base/utf_string_conversions.h"
#include "base/win/scoped_handle.h"
+#include "base/win/scoped_process_information.h"
#include "ipc/ipc_channel_proxy.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_message_macros.h"
@@ -207,7 +208,7 @@ bool LaunchProcessAsUser(const FilePath& binary,
string16 application_name = binary.value();
string16 desktop = ASCIIToUTF16(kDefaultDesktopName);
- PROCESS_INFORMATION process_info;
+ base::win::ScopedProcessInformation process_info;
STARTUPINFOW startup_info;
memset(&startup_info, 0, sizeof(startup_info));
@@ -224,14 +225,13 @@ bool LaunchProcessAsUser(const FilePath& binary,
NULL,
NULL,
&startup_info,
- &process_info)) {
+ process_info.Receive())) {
LOG_GETLASTERROR(ERROR) <<
"Failed to launch a process with a user token";
return false;
}
- CloseHandle(process_info.hThread);
- process_out->set_handle(process_info.hProcess);
+ process_out->set_handle(process_info.TakeProcessHandle());
return true;
}
« base/win/scoped_process_information.cc ('K') | « base/win/scoped_process_information_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698