mirror of
https://github.com/reactos/wine.git
synced 2024-11-29 06:30:37 +00:00
Make RegisterClassExA check that reserved bytes is a valid value.
Tests to confirm this behaviour.
This commit is contained in:
parent
dd99a50f37
commit
e4c2d6ba8c
@ -310,6 +310,7 @@ static void test_instances(void)
|
||||
|
||||
cls.lpszMenuName = "main_module";
|
||||
cls.hInstance = main_module;
|
||||
|
||||
ok( RegisterClassA( &cls ), "Failed to register local class for main module\n" );
|
||||
check_class( main_module, name, "main_module" );
|
||||
check_instance( name, main_module, main_module, main_module );
|
||||
@ -324,6 +325,29 @@ static void test_instances(void)
|
||||
check_thread_instance( name, kernel32, kernel32, kernel32 );
|
||||
ok( UnregisterClassA( name, kernel32 ), "Unregister failed for kernel32\n" );
|
||||
|
||||
/* Bug 2631 - Supplying an invalid number of bytes fails */
|
||||
cls.cbClsExtra = 0;
|
||||
cls.cbWndExtra = -1;
|
||||
SetLastError(0xdeadbeef);
|
||||
ok( ((RegisterClassA( &cls ) == 0) && (GetLastError() == ERROR_INVALID_PARAMETER)),
|
||||
"Failed with invalid number of WndExtra bytes\n");
|
||||
|
||||
cls.cbClsExtra = -1;
|
||||
cls.cbWndExtra = 0;
|
||||
SetLastError(0xdeadbeef);
|
||||
ok( ((RegisterClassA( &cls ) == 0) && (GetLastError() == ERROR_INVALID_PARAMETER)),
|
||||
"Failed with invalid number of ClsExtra bytes\n");
|
||||
|
||||
cls.cbClsExtra = -1;
|
||||
cls.cbWndExtra = -1;
|
||||
SetLastError(0xdeadbeef);
|
||||
ok( ((RegisterClassA( &cls ) == 0) && (GetLastError() == ERROR_INVALID_PARAMETER)),
|
||||
"Failed with invalid number of ClsExtra and cbWndExtra bytes\n");
|
||||
|
||||
cls.cbClsExtra = 0;
|
||||
cls.cbWndExtra = 0;
|
||||
SetLastError(0xdeadbeef);
|
||||
|
||||
/* setting global flag doesn't change status of class */
|
||||
hwnd = CreateWindowExA( 0, name, "test", 0, 0, 0, 0, 0, 0, 0, main_module, 0 );
|
||||
SetClassLongA( hwnd, GCL_STYLE, CS_GLOBALCLASS );
|
||||
|
@ -379,11 +379,14 @@ static CLASS *CLASS_RegisterClass( ATOM atom, HINSTANCE hInstance, BOOL local,
|
||||
|
||||
/* Fix the extra bytes value */
|
||||
|
||||
if (classExtra < 0) classExtra = 0;
|
||||
else if (classExtra > 40) /* Extra bytes are limited to 40 in Win32 */
|
||||
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 < 0) winExtra = 0;
|
||||
else if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
|
||||
if (winExtra > 40) /* Extra bytes are limited to 40 in Win32 */
|
||||
WARN("Win extra bytes %d is > 40\n", winExtra );
|
||||
|
||||
classPtr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CLASS) + classExtra );
|
||||
|
Loading…
Reference in New Issue
Block a user