server: Unconditionally close APC handle in get_apc_result call.

Sebastian Lackner sebastian at fds-team.de
Wed Oct 28 20:34:02 CDT 2015


Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---

Other wineserver calls, for example get_exception_status, also close
the passed handle unconditionally. This seems to be the only place
where we close a handle at two different places depending on the result.

 dlls/ntdll/server.c |    1 -
 server/thread.c     |   15 +++++++--------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c
index f6457db..356d631 100644
--- a/dlls/ntdll/server.c
+++ b/dlls/ntdll/server.c
@@ -677,7 +677,6 @@ unsigned int server_queue_process_apc( HANDLE process, const apc_call_t *call, a
             SERVER_END_REQ;
 
             if (!ret && result->type == APC_NONE) continue;  /* APC didn't run, try again */
-            if (ret) NtClose( handle );
         }
         return ret;
     }
diff --git a/server/thread.c b/server/thread.c
index 6383000..b9ad403 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -1600,16 +1600,15 @@ DECL_HANDLER(get_apc_result)
 {
     struct thread_apc *apc;
 
-    if (!(apc = (struct thread_apc *)get_handle_obj( current->process, req->handle,
-                                                     0, &thread_apc_ops ))) return;
-    if (!apc->executed) set_error( STATUS_PENDING );
-    else
+    if ((apc = (struct thread_apc *)get_handle_obj( current->process, req->handle,
+                                                    0, &thread_apc_ops )))
     {
-        reply->result = apc->result;
-        /* close the handle directly to avoid an extra round-trip */
-        close_handle( current->process, req->handle );
+        if (apc->executed) reply->result = apc->result;
+        else set_error( STATUS_PENDING );
+
+        close_handle( current->process, req->handle );  /* avoid an extra round-trip for close */
+        release_object( apc );
     }
-    release_object( apc );
 }
 
 /* retrieve the current context of a thread */
-- 
2.6.1



More information about the wine-patches mailing list