https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ee0511b49db6197897386…
commit ee0511b49db6197897386df44078c8048a49c821
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Jul 8 02:24:13 2018 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Jul 8 15:39:50 2018 +0200
[WIN32K:NTUSER] Add diagnostic asserts in IntLinkWindow() and IntUnlinkWindow().
Don't link a window to itself in IntLinkWindow()! Add diagnostic traces for this
situation, as well as in IntLinkHwnd().
Helps in correctly fixing CORE-12071 and CORE-12085.
---
win32ss/user/ntuser/window.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/win32ss/user/ntuser/window.c b/win32ss/user/ntuser/window.c
index 027dec2a63..838d854f8f 100644
--- a/win32ss/user/ntuser/window.c
+++ b/win32ss/user/ntuser/window.c
@@ -861,19 +861,28 @@ IntLinkWindow(
PWND WndInsertAfter /* Set to NULL if top sibling */
)
{
+ if (Wnd == WndInsertAfter)
+ {
+ ERR("IntLinkWindow -- Trying to link window 0x%p to itself!!\n", Wnd);
+ return;
+ }
+
Wnd->spwndPrev = WndInsertAfter;
if (Wnd->spwndPrev)
{
/* Link after WndInsertAfter */
+ ASSERT(Wnd != WndInsertAfter->spwndNext);
Wnd->spwndNext = WndInsertAfter->spwndNext;
if (Wnd->spwndNext)
Wnd->spwndNext->spwndPrev = Wnd;
+ ASSERT(Wnd != Wnd->spwndPrev);
Wnd->spwndPrev->spwndNext = Wnd;
}
else
{
/* Link at the top */
+ ASSERT(Wnd != Wnd->spwndParent->spwndChild);
Wnd->spwndNext = Wnd->spwndParent->spwndChild;
if (Wnd->spwndNext)
Wnd->spwndNext->spwndPrev = Wnd;
@@ -956,6 +965,8 @@ VOID FASTCALL IntLinkHwnd(PWND Wnd, HWND hWndPrev)
return;
}
+ if (Wnd == WndInsertAfter)
+ ERR("IntLinkHwnd -- Trying to link window 0x%p to itself!!\n",
Wnd);
IntLinkWindow(Wnd, WndInsertAfter);
/* Fix the WS_EX_TOPMOST flag */
@@ -1254,6 +1265,9 @@ co_UserSetParent(HWND hWndChild, HWND hWndNewParent)
VOID FASTCALL
IntUnlinkWindow(PWND Wnd)
{
+ ASSERT(Wnd != Wnd->spwndNext);
+ ASSERT(Wnd != Wnd->spwndPrev);
+
if (Wnd->spwndNext)
Wnd->spwndNext->spwndPrev = Wnd->spwndPrev;