Skip to content

Commit bd027c9

Browse files
authored
[NTUSER] Fix 'Trying to link windows to itself' (reactos#4478) CORE-18132
Fix 'Trying to link windows to itself' on DestroyWindow. Patch by I_Kill_Bugs. This fixes a potential BSOD 0x50 observable in the app Localizer Editor"
1 parent efd11b7 commit bd027c9

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

win32ss/user/ntuser/winpos.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,8 +1393,34 @@ WinPosDoOwnedPopups(PWND Window, HWND hWndInsertAfter)
13931393

13941394
if (List[i] == Owner)
13951395
{
1396-
if (i > 0) hWndInsertAfter = List[i-1];
1397-
else hWndInsertAfter = topmost ? HWND_TOPMOST : HWND_TOP;
1396+
/* We found its Owner, so we must handle it here. */
1397+
if (i > 0)
1398+
{
1399+
if (List[i - 1] != UserHMGetHandle(Window))
1400+
{
1401+
/*
1402+
* If the popup to be inserted is not already just
1403+
* before the Owner, insert it there. The modified
1404+
* hWndInsertAfter will be handled below.
1405+
*
1406+
* (NOTE: Do not allow hWndInsertAfter to become equal
1407+
* to the popup's window handle, as this would cause
1408+
* the popup to link to itself).
1409+
*/
1410+
hWndInsertAfter = List[i - 1];
1411+
}
1412+
else
1413+
{
1414+
/* If the popup to be inserted is already
1415+
* before the Owner, we are done. */
1416+
ExFreePoolWithTag(List, USERTAG_WINDOWLIST);
1417+
return hWndInsertAfter;
1418+
}
1419+
}
1420+
else
1421+
{
1422+
hWndInsertAfter = topmost ? HWND_TOPMOST : HWND_TOP;
1423+
}
13981424
break;
13991425
}
14001426

0 commit comments

Comments
 (0)