Commit a823177c authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

win32u: Avoid truncating ToUnicodeEx result if there's room.

parent 0d137ddb
...@@ -1187,27 +1187,25 @@ INT WINAPI NtUserToUnicodeEx( UINT virt, UINT scan, const BYTE *state, ...@@ -1187,27 +1187,25 @@ INT WINAPI NtUserToUnicodeEx( UINT virt, UINT scan, const BYTE *state,
WCHAR *str, int size, UINT flags, HKL layout ) WCHAR *str, int size, UINT flags, HKL layout )
{ {
const KBDTABLES *kbd_tables; const KBDTABLES *kbd_tables;
WCHAR buffer[2] = {0};
INT len; INT len;
TRACE_(keyboard)( "virt %#x, scan %#x, state %p, str %p, size %d, flags %#x, layout %p.\n", TRACE_(keyboard)( "virt %#x, scan %#x, state %p, str %p, size %d, flags %#x, layout %p.\n",
virt, scan, state, str, size, flags, layout ); virt, scan, state, str, size, flags, layout );
if (!state) return 0; if (!state || !size) return 0;
if ((len = user_driver->pToUnicodeEx( virt, scan, state, str, size, flags, layout )) >= -1) return len; if ((len = user_driver->pToUnicodeEx( virt, scan, state, str, size, flags, layout )) >= -1) return len;
if (!(kbd_tables = user_driver->pKbdLayerDescriptor( layout ))) kbd_tables = &kbdus_tables; if (!(kbd_tables = user_driver->pKbdLayerDescriptor( layout ))) kbd_tables = &kbdus_tables;
if (scan & 0x8000) buffer[0] = 0; /* key up */ if (scan & 0x8000) str[0] = 0; /* key up */
else buffer[0] = kbd_tables_vkey_to_wchar( kbd_tables, virt, state ); else str[0] = kbd_tables_vkey_to_wchar( kbd_tables, virt, state );
if (size > 1) str[1] = 0;
if (buffer[0] != WCH_NONE) len = 1; if (str[0] != WCH_NONE) len = 1;
else buffer[0] = len = 0; else str[0] = len = 0;
lstrcpynW( str, buffer, size );
if (kbd_tables != &kbdus_tables) user_driver->pReleaseKbdTables( kbd_tables ); if (kbd_tables != &kbdus_tables) user_driver->pReleaseKbdTables( kbd_tables );
TRACE_(keyboard)( "ret %d, str %s.\n", len, debugstr_w(str) ); TRACE_(keyboard)( "ret %d, str %s.\n", len, debugstr_wn(str, len) );
return len; return len;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment