winex11: Have ToUnicodeEx null-terminate the output buffer, if there's room.

This commit is contained in:
Ken Thomases 2011-12-19 21:59:56 -06:00 committed by Alexandre Julliard
parent c2f3c1114f
commit 3fa4da76ea
1 changed files with 6 additions and 0 deletions

View File

@ -2680,6 +2680,12 @@ INT CDECL X11DRV_ToUnicodeEx(UINT virtKey, UINT scanCode, const BYTE *lpKeyState
found:
if (buf != lpChar)
HeapFree(GetProcessHeap(), 0, lpChar);
/* Null-terminate the buffer, if there's room. MSDN clearly states that the
caller must not assume this is done, but some programs (e.g. Audiosurf) do. */
if (1 <= ret && ret < bufW_size)
bufW[ret] = 0;
TRACE_(key)("returning %d with %s\n", ret, debugstr_wn(bufW, ret));
return ret;
}