diff --git a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c index 612495571e6..6634a2c408e 100644 --- a/reactos/subsystems/win32/win32k/ntuser/msgqueue.c +++ b/reactos/subsystems/win32/win32k/ntuser/msgqueue.c @@ -965,13 +965,14 @@ MsqRemoveWindowMessagesFromQueue(PVOID pWindow) ListHead = &MessageQueue->SentMessagesListHead; while (CurrentEntry != ListHead) { - CurrentEntry = RemoveHeadList(&MessageQueue->SentMessagesListHead); SentMessage = CONTAINING_RECORD(CurrentEntry, USER_SENT_MESSAGE, ListEntry); if(SentMessage->Msg.hwnd == Window->hSelf) { DPRINT("Notify the sender and remove a message from the queue that had not been dispatched\n"); + RemoveEntryList(&SentMessage->ListEntry); + /* remove the message from the dispatching list */ if(SentMessage->DispatchingListEntry.Flink != NULL) {