WININET: allocation the correct size string in InternetCrackUrl

Mike McCormack mike at codeweavers.com
Wed Jun 30 18:50:19 CDT 2004


ChangeLog:
* allocation the correct size string in InternetCrackUrl
-------------- next part --------------
Index: dlls/wininet/internet.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/internet.c,v
retrieving revision 1.89
diff -u -r1.89 internet.c
--- dlls/wininet/internet.c	28 Jun 2004 20:28:38 -0000	1.89
+++ dlls/wininet/internet.c	1 Jul 2004 00:47:10 -0000
@@ -1024,11 +1024,13 @@
   DWORD nLength;
   URL_COMPONENTSW UCW;
   WCHAR* lpwszUrl;
-  if(dwUrlLength==0)
-      dwUrlLength=strlen(lpszUrl);
-  lpwszUrl=HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(dwUrlLength+1));
-  memset(lpwszUrl,0,sizeof(WCHAR)*(dwUrlLength+1));
-  nLength=MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,dwUrlLength+1);
+
+  if(dwUrlLength<=0)
+      dwUrlLength=-1;
+  nLength=MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,NULL,0);
+  lpwszUrl=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WCHAR)*nLength);
+  MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength);
+
   memset(&UCW,0,sizeof(UCW));
   if(lpUrlComponents->dwHostNameLength!=0)
       UCW.dwHostNameLength=1;


More information about the wine-patches mailing list