https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6ee2f9882c9cf1ff32f60fb3786b154e1eef94f0

commit 6ee2f9882c9cf1ff32f60fb3786b154e1eef94f0
Author:     Pierre Schweitzer <[email protected]>
AuthorDate: Mon Feb 25 22:33:31 2019 +0100
Commit:     Pierre Schweitzer <[email protected]>
CommitDate: Mon Feb 25 22:34:29 2019 +0100

    [MSAFD] Don't leak event while querying/setting socket options
---
 dll/win32/msafd/misc/dllmain.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/dll/win32/msafd/misc/dllmain.c b/dll/win32/msafd/misc/dllmain.c
index 520cf1a3ce..abb184f8e3 100644
--- a/dll/win32/msafd/misc/dllmain.c
+++ b/dll/win32/msafd/misc/dllmain.c
@@ -3298,6 +3298,7 @@ GetSocketInformation(PSOCKET_INFORMATION Socket,
         if ((Socket->SharedData->CreateFlags & SO_SYNCHRONOUS_NONALERT) != 0)
         {
             TRACE("Opened without flag WSA_FLAG_OVERLAPPED. Do nothing.\n");
+            NtClose( SockEvent );
             return 0;
         }
         if (CompletionRoutine == NULL)
@@ -3315,6 +3316,7 @@ GetSocketInformation(PSOCKET_INFORMATION Socket,
             if (!APCContext)
             {
                 ERR("Not enough memory for APC Context\n");
+                NtClose( SockEvent );
                 return WSAEFAULT;
             }
             APCContext->lpCompletionRoutine = CompletionRoutine;
@@ -3346,6 +3348,8 @@ GetSocketInformation(PSOCKET_INFORMATION Socket,
         Status = IOSB->Status;
     }
 
+    NtClose( SockEvent );
+
     TRACE("Status %x Information %d\n", Status, IOSB->Information);
 
     if (Status == STATUS_PENDING)
@@ -3371,8 +3375,6 @@ GetSocketInformation(PSOCKET_INFORMATION Socket,
         *Boolean = InfoData.Information.Boolean;
     }
 
-    NtClose( SockEvent );
-
     return NO_ERROR;
 
 }
@@ -3437,6 +3439,7 @@ SetSocketInformation(PSOCKET_INFORMATION Socket,
         if ((Socket->SharedData->CreateFlags & SO_SYNCHRONOUS_NONALERT) != 0)
         {
             TRACE("Opened without flag WSA_FLAG_OVERLAPPED. Do nothing.\n");
+            NtClose( SockEvent );
             return 0;
         }
         if (CompletionRoutine == NULL)
@@ -3454,6 +3457,7 @@ SetSocketInformation(PSOCKET_INFORMATION Socket,
             if (!APCContext)
             {
                 ERR("Not enough memory for APC Context\n");
+                NtClose( SockEvent );
                 return WSAEFAULT;
             }
             APCContext->lpCompletionRoutine = CompletionRoutine;

Reply via email to