Jacek Caban : winemac: Don't use snprintfW in macdrv_GetKeyNameText.

Alexandre Julliard julliard at winehq.org
Fri May 27 16:35:29 CDT 2022


Module: wine
Branch: master
Commit: cccec04f9aaed265854b06af6f888d94e5fcc465
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=cccec04f9aaed265854b06af6f888d94e5fcc465

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed May 25 23:48:35 2022 +0200

winemac: Don't use snprintfW in macdrv_GetKeyNameText.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>

---

 dlls/winemac.drv/keyboard.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/dlls/winemac.drv/keyboard.c b/dlls/winemac.drv/keyboard.c
index 08c76eb1389..94860f2e36c 100644
--- a/dlls/winemac.drv/keyboard.c
+++ b/dlls/winemac.drv/keyboard.c
@@ -1266,9 +1266,11 @@ INT macdrv_GetKeyNameText(LONG lparam, LPWSTR buffer, INT size)
 
             if (!len)
             {
-                static const WCHAR format[] = {'K','e','y',' ','0','x','%','0','2','x',0};
-                snprintfW(buffer, size, format, vkey);
-                len = strlenW(buffer);
+                char name[16];
+                len = sprintf(name, "Key 0x%02x", vkey);
+                len = min(len + 1, size);
+                ascii_to_unicode(buffer, name, len);
+                if (len) buffer[--len] = 0;
             }
 
             if (!len)




More information about the wine-cvs mailing list