Ken Thomases : winex11: Have ToUnicodeEx null-terminate the output buffer, if there's room.
Alexandre Julliard
julliard at winehq.org
Tue Dec 20 13:43:24 CST 2011
Module: wine
Branch: master
Commit: 3fa4da76ea2b3f2e91a42c0345e5764202a1e992
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3fa4da76ea2b3f2e91a42c0345e5764202a1e992
Author: Ken Thomases <ken at codeweavers.com>
Date: Mon Dec 19 21:59:56 2011 -0600
winex11: Have ToUnicodeEx null-terminate the output buffer, if there's room.
---
dlls/winex11.drv/keyboard.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c
index e985694..c561102 100644
--- a/dlls/winex11.drv/keyboard.c
+++ b/dlls/winex11.drv/keyboard.c
@@ -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;
}
More information about the wine-cvs
mailing list