Alexandre Julliard : user32: Moved the class extra bytes check to catch uninitialised data sooner.

Alexandre Julliard julliard at winehq.org
Mon May 19 16:25:44 CDT 2008


Module: wine
Branch: master
Commit: c362081a791632b88c96405cb66ae6347d391fae
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c362081a791632b88c96405cb66ae6347d391fae

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon May 19 20:21:48 2008 +0200

user32: Moved the class extra bytes check to catch uninitialised data sooner.

---

 dlls/user32/class.c |   21 ++++++++-------------
 1 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/dlls/user32/class.c b/dlls/user32/class.c
index ff0e1f8..1ca50f5 100644
--- a/dlls/user32/class.c
+++ b/dlls/user32/class.c
@@ -338,11 +338,6 @@ static CLASS *CLASS_RegisterClass( LPCWSTR name, HINSTANCE hInstance, BOOL local
 
     /* Fix the extra bytes value */
 
-    if (classExtra < 0 || winExtra < 0)
-    {
-         SetLastError( ERROR_INVALID_PARAMETER );
-         return NULL;
-    }
     if (classExtra > 40)  /* Extra bytes are limited to 40 in Win32 */
         WARN("Class extra bytes %d is > 40\n", classExtra);
     if (winExtra > 40)    /* Extra bytes are limited to 40 in Win32 */
@@ -526,11 +521,11 @@ ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
     CLASS *classPtr;
     HINSTANCE instance;
 
-    if (wc->hInstance == user32_module)
+    if (wc->cbClsExtra < 0 || wc->cbWndExtra < 0 ||
+        wc->hInstance == user32_module)  /* we can't register a class for user32 */
     {
-        /* we can't register a class for user32 */
-        SetLastError( ERROR_INVALID_PARAMETER );
-        return 0;
+         SetLastError( ERROR_INVALID_PARAMETER );
+         return 0;
     }
     if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL );
 
@@ -575,11 +570,11 @@ ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
     CLASS *classPtr;
     HINSTANCE instance;
 
-    if (wc->hInstance == user32_module)
+    if (wc->cbClsExtra < 0 || wc->cbWndExtra < 0 ||
+        wc->hInstance == user32_module)  /* we can't register a class for user32 */
     {
-        /* we can't register a class for user32 */
-        SetLastError( ERROR_INVALID_PARAMETER );
-        return 0;
+         SetLastError( ERROR_INVALID_PARAMETER );
+         return 0;
     }
     if (!(instance = wc->hInstance)) instance = GetModuleHandleW( NULL );
 




More information about the wine-cvs mailing list