From a644d30ee7aaf84d3692d8840a85e2072bc9df57 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 28 Oct 2015 03:12:21 +0000 Subject: [PATCH] [AFD] - Fix WSAEnumNetworkEvents failing if no event was supplied (uTorrent issue - CORE-6656) svn path=/trunk/; revision=69728 --- reactos/drivers/network/afd/afd/select.c | 30 ++++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/reactos/drivers/network/afd/afd/select.c b/reactos/drivers/network/afd/afd/select.c index 2e30ca3ba2b..2835f9c2ef0 100644 --- a/reactos/drivers/network/afd/afd/select.c +++ b/reactos/drivers/network/afd/afd/select.c @@ -344,21 +344,25 @@ AfdEnumEvents( PDEVICE_OBJECT DeviceObject, PIRP Irp, return UnlockAndMaybeComplete( FCB, STATUS_NO_MEMORY, Irp, 0 ); } - Status = ObReferenceObjectByHandle(EnumReq->Event, - EVENT_ALL_ACCESS, - *ExEventObjectType, - UserMode, - (PVOID *)&UserEvent, - NULL); - if (!NT_SUCCESS(Status)) + /* An event may optionally be provided for us to clear */ + if (EnumReq->Event != NULL) { - AFD_DbgPrint(MIN_TRACE,("Unable to reference event %x\n", Status)); - return UnlockAndMaybeComplete(FCB, Status, Irp, 0); - } + Status = ObReferenceObjectByHandle(EnumReq->Event, + EVENT_ALL_ACCESS, + *ExEventObjectType, + UserMode, + (PVOID *)&UserEvent, + NULL); + if (!NT_SUCCESS(Status)) + { + AFD_DbgPrint(MIN_TRACE,("Unable to reference event %x\n", Status)); + return UnlockAndMaybeComplete(FCB, Status, Irp, 0); + } - /* Clear the event */ - KeClearEvent(UserEvent); - ObDereferenceObject(UserEvent); + /* Clear the event */ + KeClearEvent(UserEvent); + ObDereferenceObject(UserEvent); + } /* Copy the poll state, masking out disabled events */ EnumReq->PollEvents = (FCB->PollState & ~FCB->EventSelectDisabled);