user32: Protect from setting as a window owner one of its successors.

This commit is contained in:
Dmitry Timoshkov 2010-08-04 23:00:34 +09:00 committed by Alexandre Julliard
parent 884b76657c
commit dfe6ae58af
2 changed files with 21 additions and 1 deletions

View File

@ -380,6 +380,15 @@ static void test_parent_owner(void)
check_parents( test, desktop, 0, desktop, 0, test, desktop );
/* window is now child of desktop so GWLP_HWNDPARENT changes owner from now on */
if (!is_win9x)
{
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)test );
ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
check_parents( test, desktop, 0, desktop, 0, test, desktop );
}
else
win_skip("Test creates circular window tree under Win9x/WinMe\n" );
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)child );
ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
check_parents( test, desktop, child, desktop, child, test, desktop );

View File

@ -1834,7 +1834,7 @@ DECL_HANDLER(get_desktop_window)
DECL_HANDLER(set_window_owner)
{
struct window *win = get_window( req->handle );
struct window *owner = NULL;
struct window *owner = NULL, *ptr;
if (!win) return;
if (req->owner && !(owner = get_window( req->owner ))) return;
@ -1843,6 +1843,17 @@ DECL_HANDLER(set_window_owner)
set_error( STATUS_ACCESS_DENIED );
return;
}
/* make sure owner is not a successor of window */
for (ptr = owner; ptr; ptr = ptr->owner ? get_window( ptr->owner ) : NULL)
{
if (ptr == win)
{
set_error( STATUS_INVALID_PARAMETER );
return;
}
}
reply->prev_owner = win->owner;
reply->full_owner = win->owner = owner ? owner->handle : 0;
}