Check for a NULL pointer in GetWindowTextA/W.

This commit is contained in:
Paul Vriens 2005-05-14 18:49:19 +00:00 committed by Alexandre Julliard
parent bfec8c229d
commit 4cc3b97ec1
2 changed files with 15 additions and 0 deletions

View file

@ -2771,6 +2771,15 @@ void test_scroll()
DestroyWindow( hwnd);
}
static void test_params()
{
INT rc;
/* Just a param check */
SetLastError(0xdeadbeef);
rc = GetWindowText(hwndMain2, NULL, 1024);
ok( rc==0, "GetWindowText: rc=%d err=%ld\n",rc,GetLastError());
}
START_TEST(win)
{
@ -2810,6 +2819,8 @@ START_TEST(win)
assert( hwndMain );
assert( hwndMain2 );
test_params();
test_capture_1();
test_capture_2();
test_capture_3(hwndMain, hwndMain2);

View file

@ -2223,6 +2223,8 @@ INT WINAPI GetWindowTextA( HWND hwnd, LPSTR lpString, INT nMaxCount )
{
WCHAR *buffer;
if (!lpString) return 0;
if (WIN_IsCurrentProcess( hwnd ))
return (INT)SendMessageA( hwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString );
@ -2266,6 +2268,8 @@ INT WINAPI InternalGetWindowText(HWND hwnd,LPWSTR lpString,INT nMaxCount )
*/
INT WINAPI GetWindowTextW( HWND hwnd, LPWSTR lpString, INT nMaxCount )
{
if (!lpString) return 0;
if (WIN_IsCurrentProcess( hwnd ))
return (INT)SendMessageW( hwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString );