From 5af055d8df8de27ae5fae7f7c8c31a0a05cbd3a9 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 24 Sep 2001 01:13:48 +0000 Subject: [PATCH] Avoid list corruption when linking window with HWND_BOTTOM (thanks to Gerard Patel). --- server/window.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/server/window.c b/server/window.c index 8bc91554c61..ed64145e9ec 100644 --- a/server/window.c +++ b/server/window.c @@ -174,15 +174,20 @@ DECL_HANDLER(link_window) if (req->parent && !(parent = get_window( req->parent ))) return; if (parent && req->previous) { - if (req->previous == 1) /* special case: HWND_BOTTOM */ - previous = parent->last_child; - else - if (!(previous = get_window( req->previous ))) return; - - if (previous && previous->parent != parent) /* previous must be a child of parent */ + if (req->previous == (user_handle_t)1) /* special case: HWND_BOTTOM */ { - set_error( STATUS_INVALID_PARAMETER ); - return; + previous = parent->last_child; + if (previous == win) return; /* nothing to do */ + } + else + { + if (!(previous = get_window( req->previous ))) return; + /* previous must be a child of parent, and not win itself */ + if (previous->parent != parent || previous == win) + { + set_error( STATUS_INVALID_PARAMETER ); + return; + } } } link_window( win, parent, previous );