comctl32: Add NULL checks to SetWindowSubclass (Valgrind).
Signed-off-by: Sven Baars <sven.wine@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
43f44ffb37
commit
04847e68f8
|
@ -1082,6 +1082,9 @@ BOOL WINAPI SetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass,
|
||||||
|
|
||||||
TRACE ("(%p, %p, %lx, %lx)\n", hWnd, pfnSubclass, uIDSubclass, dwRef);
|
TRACE ("(%p, %p, %lx, %lx)\n", hWnd, pfnSubclass, uIDSubclass, dwRef);
|
||||||
|
|
||||||
|
if (!hWnd || !pfnSubclass)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
/* Since the window procedure that we set here has two additional arguments,
|
/* Since the window procedure that we set here has two additional arguments,
|
||||||
* we can't simply set it as the new window procedure of the window. So we
|
* we can't simply set it as the new window procedure of the window. So we
|
||||||
* set our own window procedure and then calculate the other two arguments
|
* set our own window procedure and then calculate the other two arguments
|
||||||
|
|
|
@ -218,46 +218,61 @@ static LRESULT WINAPI wnd_proc_sub(HWND hwnd, UINT message, WPARAM wParam, LPARA
|
||||||
|
|
||||||
static void test_subclass(void)
|
static void test_subclass(void)
|
||||||
{
|
{
|
||||||
|
BOOL ret;
|
||||||
HWND hwnd = CreateWindowExA(0, "TestSubclass", "Test subclass", WS_OVERLAPPEDWINDOW,
|
HWND hwnd = CreateWindowExA(0, "TestSubclass", "Test subclass", WS_OVERLAPPEDWINDOW,
|
||||||
100, 100, 200, 200, 0, 0, 0, NULL);
|
100, 100, 200, 200, 0, 0, 0, NULL);
|
||||||
ok(hwnd != NULL, "failed to create test subclass wnd\n");
|
ok(hwnd != NULL, "failed to create test subclass wnd\n");
|
||||||
|
|
||||||
pSetWindowSubclass(hwnd, wnd_proc_sub, 2, 0);
|
ret = pSetWindowSubclass(hwnd, wnd_proc_sub, 2, 0);
|
||||||
|
ok(ret == TRUE, "Expected TRUE\n");
|
||||||
SendMessageA(hwnd, WM_USER, 1, 0);
|
SendMessageA(hwnd, WM_USER, 1, 0);
|
||||||
SendMessageA(hwnd, WM_USER, 2, 0);
|
SendMessageA(hwnd, WM_USER, 2, 0);
|
||||||
ok_sequence(Sub_BasicTest, "Basic");
|
ok_sequence(Sub_BasicTest, "Basic");
|
||||||
|
|
||||||
pSetWindowSubclass(hwnd, wnd_proc_sub, 2, DELETE_SELF);
|
ret = pSetWindowSubclass(hwnd, wnd_proc_sub, 2, DELETE_SELF);
|
||||||
|
ok(ret == TRUE, "Expected TRUE\n");
|
||||||
SendMessageA(hwnd, WM_USER, 1, 1);
|
SendMessageA(hwnd, WM_USER, 1, 1);
|
||||||
ok_sequence(Sub_DeletedTest, "Deleted");
|
ok_sequence(Sub_DeletedTest, "Deleted");
|
||||||
|
|
||||||
SendMessageA(hwnd, WM_USER, 1, 0);
|
SendMessageA(hwnd, WM_USER, 1, 0);
|
||||||
ok_sequence(Sub_AfterDeletedTest, "After Deleted");
|
ok_sequence(Sub_AfterDeletedTest, "After Deleted");
|
||||||
|
|
||||||
pSetWindowSubclass(hwnd, wnd_proc_sub, 2, 0);
|
ret = pSetWindowSubclass(hwnd, wnd_proc_sub, 2, 0);
|
||||||
|
ok(ret == TRUE, "Expected TRUE\n");
|
||||||
orig_proc_3 = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)wnd_proc_3);
|
orig_proc_3 = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)wnd_proc_3);
|
||||||
SendMessageA(hwnd, WM_USER, 1, 0);
|
SendMessageA(hwnd, WM_USER, 1, 0);
|
||||||
SendMessageA(hwnd, WM_USER, 2, 0);
|
SendMessageA(hwnd, WM_USER, 2, 0);
|
||||||
ok_sequence(Sub_OldAfterNewTest, "Old after New");
|
ok_sequence(Sub_OldAfterNewTest, "Old after New");
|
||||||
|
|
||||||
pSetWindowSubclass(hwnd, wnd_proc_sub, 4, 0);
|
ret = pSetWindowSubclass(hwnd, wnd_proc_sub, 4, 0);
|
||||||
|
ok(ret == TRUE, "Expected TRUE\n");
|
||||||
SendMessageA(hwnd, WM_USER, 1, 0);
|
SendMessageA(hwnd, WM_USER, 1, 0);
|
||||||
ok_sequence(Sub_MixTest, "Mix");
|
ok_sequence(Sub_MixTest, "Mix");
|
||||||
|
|
||||||
/* Now the fun starts */
|
/* Now the fun starts */
|
||||||
pSetWindowSubclass(hwnd, wnd_proc_sub, 4, SEND_NEST);
|
ret = pSetWindowSubclass(hwnd, wnd_proc_sub, 4, SEND_NEST);
|
||||||
|
ok(ret == TRUE, "Expected TRUE\n");
|
||||||
SendMessageA(hwnd, WM_USER, 1, 1);
|
SendMessageA(hwnd, WM_USER, 1, 1);
|
||||||
ok_sequence(Sub_MixAndNestTest, "Mix and nest");
|
ok_sequence(Sub_MixAndNestTest, "Mix and nest");
|
||||||
|
|
||||||
pSetWindowSubclass(hwnd, wnd_proc_sub, 4, SEND_NEST | DELETE_SELF);
|
ret = pSetWindowSubclass(hwnd, wnd_proc_sub, 4, SEND_NEST | DELETE_SELF);
|
||||||
|
ok(ret == TRUE, "Expected TRUE\n");
|
||||||
SendMessageA(hwnd, WM_USER, 1, 1);
|
SendMessageA(hwnd, WM_USER, 1, 1);
|
||||||
ok_sequence(Sub_MixNestDelTest, "Mix, nest, del");
|
ok_sequence(Sub_MixNestDelTest, "Mix, nest, del");
|
||||||
|
|
||||||
pSetWindowSubclass(hwnd, wnd_proc_sub, 4, 0);
|
ret = pSetWindowSubclass(hwnd, wnd_proc_sub, 4, 0);
|
||||||
pSetWindowSubclass(hwnd, wnd_proc_sub, 5, DELETE_PREV);
|
ok(ret == TRUE, "Expected TRUE\n");
|
||||||
|
ret = pSetWindowSubclass(hwnd, wnd_proc_sub, 5, DELETE_PREV);
|
||||||
|
ok(ret == TRUE, "Expected TRUE\n");
|
||||||
SendMessageA(hwnd, WM_USER, 1, 1);
|
SendMessageA(hwnd, WM_USER, 1, 1);
|
||||||
ok_sequence(Sub_MixDelPrevTest, "Mix and del prev");
|
ok_sequence(Sub_MixDelPrevTest, "Mix and del prev");
|
||||||
|
|
||||||
|
ret = pSetWindowSubclass(NULL, wnd_proc_sub, 1, 0);
|
||||||
|
ok(ret == FALSE, "Expected FALSE\n");
|
||||||
|
|
||||||
|
ret = pSetWindowSubclass(hwnd, NULL, 1, 0);
|
||||||
|
ok(ret == FALSE, "Expected FALSE\n");
|
||||||
|
|
||||||
DestroyWindow(hwnd);
|
DestroyWindow(hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue