Mike McCormack : user32: Add a test showing WM_GETTEXT doesn' t crash with bad pointers.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Jan 18 06:44:50 CST 2007


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

Author: Mike McCormack <mike at codeweavers.com>
Date:   Wed Jan 17 19:52:08 2007 +0900

user32: Add a test showing WM_GETTEXT doesn't crash with bad pointers.

---

 dlls/user32/tests/win.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index a420e28..951c6aa 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -4084,6 +4084,39 @@ static void test_ShowWindow(void)
     ok(!IsWindow(hwnd), "window should not exist\n");
 }
 
+void test_gettext(void)
+{
+    WNDCLASS cls;
+    LPCSTR clsname = "gettexttest";
+    HWND hwnd;
+    LRESULT r;
+
+    memset( &cls, 0, sizeof cls );
+    cls.lpfnWndProc = DefWindowProc;
+    cls.lpszClassName = clsname;
+    cls.hInstance = GetModuleHandle(NULL);
+
+    if (!RegisterClass( &cls )) return;
+
+    hwnd = CreateWindow( clsname, "test text", WS_OVERLAPPED, 0, 0, 10, 10, 0, NULL, NULL, NULL);
+    ok( hwnd != NULL, "window was null\n");
+
+    r = SendMessage( hwnd, WM_GETTEXT, 0x10, 0x1000);
+    ok( r == 0, "settext should return zero\n");
+
+    r = SendMessage( hwnd, WM_GETTEXT, 0x10000, 0);
+    ok( r == 0, "settext should return zero (%ld)\n", r);
+
+    r = SendMessage( hwnd, WM_GETTEXT, 0xff000000, 0x1000);
+    ok( r == 0, "settext should return zero (%ld)\n", r);
+
+    r = SendMessage( hwnd, WM_GETTEXT, 0x1000, 0xff000000);
+    ok( r == 0, "settext should return zero (%ld)\n", r);
+
+    DestroyWindow(hwnd);
+    UnregisterClass( clsname, NULL );
+}
+
 START_TEST(win)
 {
     pGetAncestor = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetAncestor" );
@@ -4161,6 +4194,7 @@ START_TEST(win)
     test_csparentdc();
     test_SetWindowLong();
     test_ShowWindow();
+    test_gettext();
 
     /* add the tests above this line */
     UnhookWindowsHookEx(hhook);




More information about the wine-cvs mailing list