[System] Fix handle leak in Process::GetProcess.
[mono.git] / mcs / class / System / System.Diagnostics / Process.cs
index 9b3fdf9dc5e26a631378240e3aba9405896f8dbd..b038095093c5b31d60332cd4de3021c0b11e0787 100644 (file)
@@ -482,7 +482,8 @@ namespace System.Diagnostics
                        if (proc == IntPtr.Zero)
                                throw new ArgumentException ("Can't find process with ID " + processId.ToString ());
 
-                       return (new Process (new SafeProcessHandle (proc, false), processId));
+                       /* The handle returned by GetProcess_internal is owned by its caller, so we must pass true to SafeProcessHandle */
+                       return (new Process (new SafeProcessHandle (proc, true), processId));
                }
 
                public static Process[] GetProcessesByName(string processName, string machineName)
@@ -849,13 +850,13 @@ namespace System.Diagnostics
                }
 
                [Obsolete ("Process.Start is not supported on the current platform.", true)]
-               public static Process Start(string fileName, string username, SecureString password, string domain)
+               public static Process Start(string fileName, string userName, SecureString password, string domain)
                {
                        throw new PlatformNotSupportedException ("Process.Start is not supported on the current platform.");
                }
 
                [Obsolete ("Process.Start is not supported on the current platform.", true)]
-               public static Process Start(string fileName, string arguments, string username, SecureString password, string domain)
+               public static Process Start(string fileName, string arguments, string userName, SecureString password, string domain)
                {
                        throw new PlatformNotSupportedException ("Process.Start is not supported on the current platform.");
                }