From e205d3ce0d27afe10ecd82657b39790a4cf4e087 Mon Sep 17 00:00:00 2001
From: Rodrigo Rivas <rodrigorivascosta@gmail.com>
Date: Tue, 25 Aug 2015 15:08:43 +0200
Subject: user32: Fix error handling in {Begin,End,}DeferWindowPos() to match
 Windows behavior (resend)

---
 dlls/user32/winpos.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c
index f92a3dc..7cb3a4f 100644
--- a/dlls/user32/winpos.c
+++ b/dlls/user32/winpos.c
@@ -2349,6 +2349,11 @@ HDWP WINAPI DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter,
 
     hwnd = WIN_GetFullHandle( hwnd );
     if (is_desktop_window( hwnd )) return 0;
+    if (!IsWindow( hwnd ))
+    {
+        SetLastError( ERROR_INVALID_WINDOW_HANDLE );
+        return 0;
+    }
 
     if (!(pDWP = get_user_handle_ptr( hdwp, USER_DWP ))) return 0;
     if (pDWP == OBJ_OTHER_PROCESS)
@@ -2418,7 +2423,6 @@ BOOL WINAPI EndDeferWindowPos( HDWP hdwp )
 {
     DWP *pDWP;
     WINDOWPOS *winpos;
-    BOOL res = TRUE;
     int i;
 
     TRACE("%p\n", hdwp);
@@ -2430,20 +2434,20 @@ BOOL WINAPI EndDeferWindowPos( HDWP hdwp )
         return FALSE;
     }
 
-    for (i = 0, winpos = pDWP->winPos; res && i < pDWP->actualCount; i++, winpos++)
+    for (i = 0, winpos = pDWP->winPos; i < pDWP->actualCount; i++, winpos++)
     {
         TRACE("hwnd %p, after %p, %d,%d (%dx%d), flags %08x\n",
                winpos->hwnd, winpos->hwndInsertAfter, winpos->x, winpos->y,
                winpos->cx, winpos->cy, winpos->flags);
 
         if (WIN_IsCurrentThread( winpos->hwnd ))
-            res = USER_SetWindowPos( winpos );
+            USER_SetWindowPos( winpos );
         else
-            res = SendMessageW( winpos->hwnd, WM_WINE_SETWINDOWPOS, 0, (LPARAM)winpos );
+            SendMessageW( winpos->hwnd, WM_WINE_SETWINDOWPOS, 0, (LPARAM)winpos );
     }
     HeapFree( GetProcessHeap(), 0, pDWP->winPos );
     HeapFree( GetProcessHeap(), 0, pDWP );
-    return res;
+    return TRUE;
 }
 
 
-- 
2.5.0

