Alexandre Julliard : server: Always free the process handle table even if the process didn't start.

Alexandre Julliard julliard at winehq.org
Tue Aug 24 11:09:15 CDT 2010


Module: wine
Branch: master
Commit: 350c0caba0e0db23acaade79e2f2170a5295a111
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=350c0caba0e0db23acaade79e2f2170a5295a111

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Aug 24 12:10:51 2010 +0200

server: Always free the process handle table even if the process didn't start.

---

 server/handle.c  |    9 +++++++++
 server/handle.h  |    1 +
 server/process.c |    6 ++----
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/server/handle.c b/server/handle.c
index 4e52f0e..2aaec37 100644
--- a/server/handle.c
+++ b/server/handle.c
@@ -171,6 +171,15 @@ static void handle_table_destroy( struct object *obj )
     free( table->entries );
 }
 
+/* close all the process handles and free the handle table */
+void close_process_handles( struct process *process )
+{
+    struct handle_table *table = process->handles;
+
+    process->handles = NULL;
+    if (table) release_object( table );
+}
+
 /* allocate a new handle table */
 struct handle_table *alloc_handle_table( struct process *process, int count )
 {
diff --git a/server/handle.h b/server/handle.h
index 7860f52..821c4ef 100644
--- a/server/handle.h
+++ b/server/handle.h
@@ -49,6 +49,7 @@ extern obj_handle_t open_object( const struct namespace *namespace, const struct
 extern obj_handle_t find_inherited_handle( struct process *process, const struct object_ops *ops );
 extern obj_handle_t enumerate_handles( struct process *process, const struct object_ops *ops,
                                        unsigned int *index );
+extern void close_process_handles( struct process *process );
 extern struct handle_table *alloc_handle_table( struct process *process, int count );
 extern struct handle_table *copy_handle_table( struct process *process, struct process *parent );
 extern unsigned int get_handle_table_count( struct process *process);
diff --git a/server/process.c b/server/process.c
index 36e462a..a3aa586 100644
--- a/server/process.c
+++ b/server/process.c
@@ -416,6 +416,7 @@ static void process_destroy( struct object *obj )
 
     assert( !process->sigkill_timeout );  /* timeout should hold a reference to the process */
 
+    close_process_handles( process );
     set_process_startup_state( process, STARTUP_ABORTED );
     if (process->console) release_object( process->console );
     if (process->parent) release_object( process->parent );
@@ -615,15 +616,12 @@ void kill_console_processes( struct thread *renderer, int exit_code )
 /* a process has been killed (i.e. its last thread died) */
 static void process_killed( struct process *process )
 {
-    struct handle_table *handles;
     struct list *ptr;
 
     assert( list_empty( &process->thread_list ));
     process->end_time = current_time;
     if (!process->is_system) close_process_desktop( process );
-    handles = process->handles;
-    process->handles = NULL;
-    if (handles) release_object( handles );
+    close_process_handles( process );
     process->winstation = 0;
     process->desktop = 0;
     if (process->idle_event)




More information about the wine-cvs mailing list