Comparing pid instead of handles in GetModules_internal (#3575)
authorHenric Müller <henric.muller@gmail.com>
Thu, 29 Sep 2016 15:19:43 +0000 (17:19 +0200)
committerMiguel de Icaza <miguel@gnome.org>
Thu, 29 Sep 2016 15:19:43 +0000 (11:19 -0400)
Process handles can be different for same process id.
Therefore make sure we compare the process ids instead.

mono/metadata/process.c

index 8178d283823e569dedf444dc828df54cdfbc324d..96814db8480518f5f35f83caea8c66f18a9ec520 100644 (file)
@@ -489,16 +489,10 @@ ves_icall_System_Diagnostics_Process_GetModules_internal (MonoObject *this_obj,
        guint32 count = 0, module_count = 0, assembly_count = 0;
        guint32 i, num_added = 0;
        GPtrArray *assemblies = NULL;
-       static HANDLE current_process = 0;
-       
-       if (current_process == 0) {
-               int pid = mono_process_current_pid ();
-               current_process = ves_icall_System_Diagnostics_Process_GetProcess_internal (pid);
-       }
 
        stash_system_assembly (this_obj);
 
-       if (process == current_process) {
+       if (GetProcessId (process) == mono_process_current_pid ()) {
                assemblies = get_domain_assemblies (mono_domain_get ());
                assembly_count = assemblies->len;
        }