Skip to content

Commit

Permalink
[MSAFD] Don't modify APC-owned memory
Browse files Browse the repository at this point in the history
  • Loading branch information
TAN-Gaming committed Jan 14, 2024
1 parent 0c5e18b commit cbbf12d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 46 deletions.
7 changes: 0 additions & 7 deletions dll/win32/msafd/misc/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -2064,13 +2064,6 @@ WSPConnect(SOCKET Handle,
return MsafdReturnWithErrno(Status, lpErrno, 0, NULL);
}

if (APCFunction)
{
APCContext->lpConnectInfo = NULL;
APCContext->lpSocket = NULL;
/* This will be freed by the APC */
// HeapFree(GlobalHeap, 0, APCContext);
}
if (ConnectInfo)
HeapFree(GlobalHeap, 0, ConnectInfo);

Expand Down
41 changes: 2 additions & 39 deletions dll/win32/msafd/misc/sndrcv.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,6 @@ WSPRecv(SOCKET Handle,
return MsafdReturnWithErrno(Status, lpErrno, IOSB->Information, lpNumberOfBytesRead);
}

if (APCFunction)
{
APCContext->lpRecvInfo = NULL;
APCContext->lpCompletionRoutine = NULL;
APCContext->lpSocket = NULL;
/* This will be freed by the APC */
//HeapFree(GlobalHeap, 0, APCContext);
}

/* Return the Flags */
if (ReceiveFlags)
{
Expand Down Expand Up @@ -583,15 +574,6 @@ WSPRecvFrom(SOCKET Handle,
return MsafdReturnWithErrno(Status, lpErrno, IOSB->Information, lpNumberOfBytesRead);
}

if (APCFunction)
{
APCContext->lpRecvInfo = NULL;
APCContext->lpCompletionRoutine = NULL;
APCContext->lpSocket = NULL;
/* This will be freed by the APC */
//HeapFree(GlobalHeap, 0, APCContext);
}

if (ReceiveFlags)
{
/* Return the Flags */
Expand Down Expand Up @@ -775,15 +757,6 @@ WSPSend(SOCKET Handle,
return MsafdReturnWithErrno(Status, lpErrno, IOSB->Information, lpNumberOfBytesSent);
}

if (APCFunction)
{
APCContext->lpSendInfo = NULL;
APCContext->lpCompletionRoutine = NULL;
APCContext->lpSocket = NULL;
/* This will be freed by the APC */
//HeapFree(GlobalHeap, 0, APCContext);
}

/* Re-enable Async Event */
SockReenableAsyncSelectEvent(Socket, FD_WRITE);

Expand Down Expand Up @@ -981,7 +954,7 @@ WSPSendTo(SOCKET Handle,
}

NtClose(SockEvent);

HeapFree(GlobalHeap, 0, RemoteAddress);
if (BindAddress != NULL)
{
HeapFree(GlobalHeap, 0, BindAddress);
Expand All @@ -992,17 +965,7 @@ WSPSendTo(SOCKET Handle,
TRACE("Leaving (Pending)\n");
return MsafdReturnWithErrno(Status, lpErrno, IOSB->Information, lpNumberOfBytesSent);
}

if (APCFunction)
{
APCContext->lpSendInfo = NULL;
APCContext->lpRemoteAddress = NULL;
APCContext->lpCompletionRoutine = NULL;
APCContext->lpSocket = NULL;
/* This will be freed by the APC */
//HeapFree(GlobalHeap, 0, APCContext);
}
HeapFree(GlobalHeap, 0, RemoteAddress);

SockReenableAsyncSelectEvent(Socket, FD_WRITE);

TRACE("Leaving (%ld %ld)\n", Status, IOSB->Information);
Expand Down

0 comments on commit cbbf12d

Please sign in to comment.