Truncate the window text if it is too large for the request buffer.

This commit is contained in:
Alexandre Julliard 2001-11-16 18:14:17 +00:00
parent d9ed57ac99
commit 44cd974fff
1 changed files with 8 additions and 4 deletions

View File

@ -75,13 +75,15 @@ static void DEFWND_SetTextA( HWND hwnd, LPCSTR text )
if (!(wndPtr = WIN_GetPtr( hwnd ))) return;
if ((textW = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR))))
{
size_t len = min( REQUEST_MAX_VAR_SIZE, (count-1) * sizeof(WCHAR) );
if (wndPtr->text) HeapFree(GetProcessHeap(), 0, wndPtr->text);
wndPtr->text = textW;
MultiByteToWideChar( CP_ACP, 0, text, -1, textW, count );
SERVER_START_VAR_REQ( set_window_text, (count-1) * sizeof(WCHAR) )
SERVER_START_VAR_REQ( set_window_text, len )
{
req->handle = hwnd;
memcpy( server_data_ptr(req), textW, (count-1) * sizeof(WCHAR) );
memcpy( server_data_ptr(req), textW, len );
SERVER_CALL();
}
SERVER_END_VAR_REQ;
@ -111,11 +113,13 @@ static void DEFWND_SetTextW( HWND hwnd, LPCWSTR text )
if (wndPtr->text) HeapFree(GetProcessHeap(), 0, wndPtr->text);
if ((wndPtr->text = HeapAlloc(GetProcessHeap(), 0, count * sizeof(WCHAR))))
{
size_t len = min( REQUEST_MAX_VAR_SIZE, (count-1) * sizeof(WCHAR) );
strcpyW( wndPtr->text, text );
SERVER_START_VAR_REQ( set_window_text, (count-1) * sizeof(WCHAR) )
SERVER_START_VAR_REQ( set_window_text, len )
{
req->handle = hwnd;
memcpy( server_data_ptr(req), wndPtr->text, (count-1) * sizeof(WCHAR) );
memcpy( server_data_ptr(req), wndPtr->text, len );
SERVER_CALL();
}
SERVER_END_VAR_REQ;