Zhiyi Zhang : winecfg: Fix a crash when inputting non-ASCII dll override name.

Alexandre Julliard julliard at winehq.org
Mon Dec 18 14:17:02 CST 2017


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

Author: Zhiyi Zhang <yi.gd.cn at gmail.com>
Date:   Mon Dec 18 22:33:08 2017 +0800

winecfg: Fix a crash when inputting non-ASCII dll override name.

Signed-off-by: Zhiyi Zhang <yi.gd.cn at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/winecfg/winecfg.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/programs/winecfg/winecfg.c b/programs/winecfg/winecfg.c
index dbac929..ba317c7 100644
--- a/programs/winecfg/winecfg.c
+++ b/programs/winecfg/winecfg.c
@@ -571,7 +571,7 @@ char **enumerate_values(HKEY root, char *path)
     WCHAR *wpath;
     WCHAR **wret;
     char **ret=NULL;
-    int i=0, len=0;
+    int i=0, len=0, size;
 
     wpath = HeapAlloc(GetProcessHeap(), 0, (strlen(path)+1)*sizeof(WCHAR));
     MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, strlen(path)+1);
@@ -586,11 +586,13 @@ char **enumerate_values(HKEY root, char *path)
         /* convert WCHAR ** to char ** and HeapFree each WCHAR * element on our way */
         for (i=0; i<len; i++)
         {
-            ret[i] = HeapAlloc(GetProcessHeap(), 0,
-                               (lstrlenW(wret[i]) + 1) * sizeof(char));
-            WideCharToMultiByte(CP_ACP, 0, wret[i], -1, ret[i],
-                                lstrlenW(wret[i]) + 1, NULL, NULL);
-            HeapFree(GetProcessHeap(), 0, wret[i]);
+            size = WideCharToMultiByte(CP_ACP, 0, wret[i], -1, NULL, 0, NULL, NULL);
+            if(size)
+            {
+                ret[i] = HeapAlloc(GetProcessHeap(), 0, size);
+                WideCharToMultiByte(CP_ACP, 0, wret[i], -1, ret[i], size, NULL, NULL);
+                HeapFree(GetProcessHeap(), 0, wret[i]);
+            }
         }
         ret[len] = NULL;
     }




More information about the wine-cvs mailing list