Robert Shearman : wininet: Fix some string length calculations.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Mar 31 05:08:42 CST 2006


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

Author: Robert Shearman <rob at codeweavers.com>
Date:   Thu Mar 30 19:55:36 2006 +0100

wininet: Fix some string length calculations.

Fix some string length calculations that didn't account for the
different sized characters with Unicode.

---

 dlls/wininet/urlcache.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/dlls/wininet/urlcache.c b/dlls/wininet/urlcache.c
index a4bdfa7..3557ea5 100644
--- a/dlls/wininet/urlcache.c
+++ b/dlls/wininet/urlcache.c
@@ -943,8 +943,8 @@ static BOOL URLCache_CopyEntry(
         lenUrl = MultiByteToWideChar(CP_ACP, 0, (LPSTR)pUrlEntry + pUrlEntry->dwOffsetUrl, -1, NULL, 0);
     else
         lenUrl = strlen((LPSTR)pUrlEntry + pUrlEntry->dwOffsetUrl);
-    dwRequiredSize += lenUrl + 1;
-    
+    dwRequiredSize += (lenUrl + 1) * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
+
     /* FIXME: is source url optional? */
     if (*lpdwBufferSize >= dwRequiredSize)
     {
@@ -970,7 +970,7 @@ static BOOL URLCache_CopyEntry(
         {
             lpCacheEntryInfo->lpszLocalFileName = lpszLocalFileName;
         }
-        dwRequiredSize += nLocalFilePathSize;
+        dwRequiredSize += nLocalFilePathSize * (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)) ;
 
         if ((dwRequiredSize % 4) && (dwRequiredSize < *lpdwBufferSize))
             ZeroMemory((LPBYTE)lpCacheEntryInfo + dwRequiredSize, 4 - (dwRequiredSize % 4));




More information about the wine-cvs mailing list