[PATCH 11/14] user32: Use a label to handle errors in WIN_CreateWindowEx

Pierre d'Herbemont pdherbemont at free.fr
Sun Jan 21 17:36:59 CST 2007


---
   dlls/user32/win.c |   39 +++++++++++----------------------------
   1 files changed, 11 insertions(+), 28 deletions(-)

-------------- next part --------------
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index e8961c2..c453253 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -1121,8 +1121,7 @@ static HWND WIN_CreateWindowEx( CREATEST
     if (HOOK_CallHooks( WH_CBT, HCBT_CREATEWND, (WPARAM)hwnd, (LPARAM)&cbtc, unicode ))
     {
         TRACE("CBT-hook returned !0\n");
-        WIN_DestroyWindow( hwnd );
-        return 0;
+        goto failed;
     }
 
     /* Send the WM_GETMINMAXINFO message and fix the size if needed */
@@ -1149,16 +1148,11 @@ static HWND WIN_CreateWindowEx( CREATEST
     if (!ret)
     {
         WARN("aborted by WM_xxCREATE!\n");
-        WIN_DestroyWindow( hwnd );
-        return 0;
+        goto failed;
     }
 
     /* send WM_NCCALCSIZE */
-    if (!(wndPtr = WIN_GetPtr(hwnd)))
-    {
-        WIN_DestroyWindow( hwnd );
-        return 0;
-    }
+    if (!(wndPtr = WIN_GetPtr(hwnd))) goto failed;
 
     rect = wndPtr->rectWindow;
     
@@ -1166,11 +1160,7 @@ static HWND WIN_CreateWindowEx( CREATEST
 
     SendMessageW( hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rect );
 
-    if (!(wndPtr = WIN_GetPtr(hwnd)))
-    {
-        WIN_DestroyWindow( hwnd );
-        return 0;
-    }
+    if (!(wndPtr = WIN_GetPtr(hwnd))) goto failed;
 
     /* yes, even if the CBT hook was called with HWND_TOP */
     insert_after = (wndPtr->dwStyle & WS_CHILD) ? HWND_BOTTOM : HWND_TOP;
@@ -1190,17 +1180,9 @@ static HWND WIN_CreateWindowEx( CREATEST
     else
         ret = (SendMessageA( hwnd, WM_CREATE, 0, (LPARAM)cs ) != -1);
 
-    if (!ret)
-    {
-        WIN_DestroyWindow( hwnd );
-        return 0;
-    }
+    if (!ret) goto failed;
 
-    if (!(wndPtr = WIN_GetPtr(hwnd)))
-    {
-        WIN_DestroyWindow( hwnd );
-        return 0;
-    }
+    if (!(wndPtr = WIN_GetPtr(hwnd))) goto failed;
 
     client_rect = wndPtr->rectClient;
     window_rect = wndPtr->rectWindow;
@@ -1208,10 +1190,7 @@ static HWND WIN_CreateWindowEx( CREATEST
     WIN_ReleasePtr( wndPtr );
 
     if (!USER_Driver->pCreateWindow( hwnd, cs, &window_rect, &client_rect, insert_after, unicode))
-    {
-        WIN_DestroyWindow( hwnd );
-        return 0;
-    }
+        goto failed;
 
     /* Notify the parent window only */
 
@@ -1241,6 +1220,10 @@ static HWND WIN_CreateWindowEx( CREATEST
 
     TRACE("created window %p\n", hwnd);
     return hwnd;
+
+failed:
+    WIN_DestroyWindow( hwnd );
+    return 0;
 }
 
 


More information about the wine-patches mailing list