[Janitorial] HeapAlloc for WSTR must allocate len* sizeof(WCHARS)

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Tue Jun 29 08:53:27 CDT 2004


Changelog:
	wine/dlls/mpr/wnet.c, wine/dlls/imm32/imm.c,
	wine/dlls/hhctrl.ocx/hhctrl.c:
	Allocate len * sizeof(WCHAR) for WSTR
-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Index: wine/dlls/mpr/wnet.c
===================================================================
RCS file: /home/wine/wine/dlls/mpr/wnet.c,v
retrieving revision 1.16
diff -u -w -5 -r1.16 wnet.c
--- wine/dlls/mpr/wnet.c	7 May 2004 03:59:41 -0000	1.16
+++ wine/dlls/mpr/wnet.c	29 Jun 2004 13:52:50 -0000
@@ -1538,11 +1538,11 @@
     {
         int len = MultiByteToWideChar(CP_ACP, 0, lpLocalName, -1, NULL, 0);
 
         if (len)
         {
-            PWSTR wideLocalName = (PWSTR)HeapAlloc(GetProcessHeap(), 0, len);
+            PWSTR wideLocalName = (PWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
 
             if (wideLocalName)
             {
                 WCHAR wideRemoteStatic[MAX_PATH];
                 DWORD wideRemoteSize = sizeof(wideRemoteStatic) / sizeof(WCHAR);
Index: wine/dlls/imm32/imm.c
===================================================================
RCS file: /home/wine/wine/dlls/imm32/imm.c,v
retrieving revision 1.32
diff -u -w -5 -r1.32 imm.c
--- wine/dlls/imm32/imm.c	4 Mar 2004 06:06:44 -0000	1.32
+++ wine/dlls/imm32/imm.c	29 Jun 2004 13:52:50 -0000
@@ -1263,18 +1263,18 @@
             hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
 
     comp_len = MultiByteToWideChar(CP_ACP, 0, lpComp, dwCompLen, NULL, 0);
     if (comp_len)
     {
-        CompBuffer = (WCHAR*)HeapAlloc(GetProcessHeap(),0,comp_len);
+        CompBuffer = (WCHAR*)HeapAlloc(GetProcessHeap(),0,comp_len * sizeof(WCHAR));
         MultiByteToWideChar(CP_ACP, 0, lpComp, dwCompLen, CompBuffer, comp_len);
     }
 
     read_len = MultiByteToWideChar(CP_ACP, 0, lpRead, dwReadLen, NULL, 0);
     if (read_len)
     {
-        ReadBuffer = (WCHAR*)HeapAlloc(GetProcessHeap(),0,read_len);
+        ReadBuffer = (WCHAR*)HeapAlloc(GetProcessHeap(),0,read_len * sizeof(WCHAR));
         MultiByteToWideChar(CP_ACP, 0, lpRead, dwReadLen, ReadBuffer, read_len);
     }
 
     rc =  ImmSetCompositionStringW(hIMC, dwIndex, CompBuffer, comp_len,
                                    ReadBuffer, read_len);
Index: wine/dlls/hhctrl.ocx/hhctrl.c
===================================================================
RCS file: /home/wine/wine/dlls/hhctrl.ocx/hhctrl.c,v
retrieving revision 1.2
diff -u -w -5 -r1.2 hhctrl.c
--- wine/dlls/hhctrl.ocx/hhctrl.c	1 Jun 2004 19:44:59 -0000	1.2
+++ wine/dlls/hhctrl.ocx/hhctrl.c	29 Jun 2004 13:52:50 -0000
@@ -45,11 +45,11 @@
 {
     WCHAR *wfile = NULL;
     DWORD len = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 );
     HWND result;
 
-    wfile = HeapAlloc( GetProcessHeap(), 0, len );
+    wfile = HeapAlloc( GetProcessHeap(), 0, len  * sizeof(WCHAR));
     MultiByteToWideChar( CP_ACP, 0, filename, -1, wfile, len );
 
     result = HtmlHelpW( caller, wfile, command, data );
 
     HeapFree( GetProcessHeap(), 0, wfile );



More information about the wine-patches mailing list