On WM_GETTEXT, terminate the lparam buffer even if string is empty.

This commit is contained in:
Duane Clark 2002-03-20 01:31:03 +00:00 committed by Alexandre Julliard
parent b4994d18e9
commit f9340ff94d
1 changed files with 12 additions and 4 deletions

View File

@ -794,15 +794,19 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
break;
case WM_GETTEXT:
{
WND *wndPtr = WIN_GetPtr( hwnd );
if (wParam && wndPtr && wndPtr->text)
if (wParam)
{
LPSTR dest = (LPSTR)lParam;
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr) break;
if (wndPtr->text)
{
if (!WideCharToMultiByte( CP_ACP, 0, wndPtr->text, -1,
dest, wParam, NULL, NULL )) dest[wParam-1] = 0;
result = strlen( dest );
}
else dest[0] = '\0';
WIN_ReleasePtr( wndPtr );
}
break;
@ -928,14 +932,18 @@ LRESULT WINAPI DefWindowProcW(
break;
case WM_GETTEXT:
{
WND *wndPtr = WIN_GetPtr( hwnd );
if (wParam && wndPtr && wndPtr->text)
if (wParam)
{
LPWSTR dest = (LPWSTR)lParam;
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr) break;
if (wndPtr->text)
{
lstrcpynW( dest, wndPtr->text, wParam );
result = strlenW( dest );
}
else dest[0] = '\0';
WIN_ReleasePtr( wndPtr );
}
break;