Vitaliy Margolen : user: Set buffer to '\0' in GetKeyNameTextA too.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jul 31 04:32:15 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 066e0d5b1b2b892d57896f34ad3b7d9e2c38bd00
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=066e0d5b1b2b892d57896f34ad3b7d9e2c38bd00

Author: Vitaliy Margolen <wine-patch at kievinfo.com>
Date:   Sat Jul 29 19:28:26 2006 -0600

user: Set buffer to '\0' in GetKeyNameTextA too.

---

 dlls/user/input.c       |    3 +++
 dlls/user/tests/input.c |   14 ++++++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/dlls/user/input.c b/dlls/user/input.c
index 26c3b96..24ffed7 100644
--- a/dlls/user/input.c
+++ b/dlls/user/input.c
@@ -595,7 +595,10 @@ INT WINAPI GetKeyNameTextA(LONG lParam, 
     INT ret;
 
     if (!GetKeyNameTextW(lParam, buf, 256))
+    {
+        lpBuffer[0] = 0;
         return 0;
+    }
     ret = WideCharToMultiByte(CP_ACP, 0, buf, -1, lpBuffer, nSize, NULL, NULL);
     if (!ret && nSize)
     {
diff --git a/dlls/user/tests/input.c b/dlls/user/tests/input.c
index 7627f42..f87be76 100644
--- a/dlls/user/tests/input.c
+++ b/dlls/user/tests/input.c
@@ -521,8 +521,22 @@ static void test_Input_blackbox(void)
     DestroyWindow(window);
 }
 
+static void test_keynames(void)
+{
+    int i, len;
+    char buff[256];
+
+    for (i = 0; i < 512; i++)
+    {
+        strcpy(buff, "----");
+        len = GetKeyNameTextA(i << 16, buff, sizeof(buff));
+        ok(len || !buff[0], "%d: Buffer is not zeroed\n", i);
+    }
+}
+
 START_TEST(input)
 {
     test_Input_whitebox();
     test_Input_blackbox();
+    test_keynames();
 }




More information about the wine-cvs mailing list