Commit 3fa4da76 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

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

parent c2f3c111
...@@ -2680,6 +2680,12 @@ INT CDECL X11DRV_ToUnicodeEx(UINT virtKey, UINT scanCode, const BYTE *lpKeyState ...@@ -2680,6 +2680,12 @@ INT CDECL X11DRV_ToUnicodeEx(UINT virtKey, UINT scanCode, const BYTE *lpKeyState
found: found:
if (buf != lpChar) if (buf != lpChar)
HeapFree(GetProcessHeap(), 0, 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)); TRACE_(key)("returning %d with %s\n", ret, debugstr_wn(bufW, ret));
return ret; return ret;
} }
......
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