From 6ee2f9882c9cf1ff32f60fb3786b154e1eef94f0 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Mon, 25 Feb 2019 22:33:31 +0100 Subject: [PATCH] [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 520cf1a3ce1..abb184f8e34 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;