[PATCH] wininet: NULL-terminate url string passed to InternetCrackUrlW from InternetCrackUrlA (try 2)

Nigel Liang ncliang at gmail.com
Fri Oct 5 12:47:34 CDT 2007


Changelog:
  Do not zero buffer during HeapAlloc and explicitly NULL-terminate the buffer later.
  Change suggested by Juan.
---
 dlls/wininet/internet.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 0edca74..00383ba 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -1083,8 +1083,9 @@ BOOL WINAPI InternetCrackUrlA(LPCSTR lps
        InternetCrackUrlW should not include it                  */
   if (dwUrlLength == -1) nLength--;

-  lpwszUrl=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WCHAR)*nLength);
-  MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength);
+  lpwszUrl=HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(nLength+1));
+  MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,(nLength+1));
+  lpwszUrl[nLength] = 0;

   memset(&UCW,0,sizeof(UCW));
   if(lpUrlComponents->dwHostNameLength!=0)
-- 
1.4.1




More information about the wine-patches mailing list