Sebastian Lackner : server: Avoid leaking file descriptor on error in create_thread function.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Nov 18 10:25:19 CST 2014


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

Author: Sebastian Lackner <sebastian at fds-team.de>
Date:   Mon Nov 17 19:23:13 2014 +0100

server: Avoid leaking file descriptor on error in create_thread function.

---

 server/thread.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/server/thread.c b/server/thread.c
index 97860ee..ba3f1d5 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -219,11 +219,16 @@ struct thread *create_thread( int fd, struct process *process )
 
     if (process->is_terminating)
     {
+        close( fd );
         set_error( STATUS_PROCESS_IS_TERMINATING );
         return NULL;
     }
 
-    if (!(thread = alloc_object( &thread_ops ))) return NULL;
+    if (!(thread = alloc_object( &thread_ops )))
+    {
+        close( fd );
+        return NULL;
+    }
 
     init_thread_structure( thread );
 
@@ -236,6 +241,7 @@ struct thread *create_thread( int fd, struct process *process )
 
     if (!(thread->id = alloc_ptid( thread )))
     {
+        close( fd );
         release_object( thread );
         return NULL;
     }




More information about the wine-cvs mailing list