[PATCH 3/6] urlmon: The persisted version of URL monikers should be size of URL including nul-terminating character (4-bytes), followed by the URL string including nul-terminating character.

Robert Shearman rob at codeweavers.com
Wed May 23 13:05:24 CDT 2007


---
  dlls/urlmon/umon.c |   21 ++++++++++-----------
  1 files changed, 10 insertions(+), 11 deletions(-)
-------------- next part --------------
diff --git a/dlls/urlmon/umon.c b/dlls/urlmon/umon.c
index 0f86b83..5c795f0 100644
--- a/dlls/urlmon/umon.c
+++ b/dlls/urlmon/umon.c
@@ -410,23 +410,23 @@ static HRESULT WINAPI URLMonikerImpl_Loa
     URLMonikerImpl *This = (URLMonikerImpl *)iface;
     
     HRESULT res;
-    ULONG len;
+    ULONG size;
     ULONG got;
     TRACE("(%p,%p)\n",This,pStm);
 
     if(!pStm)
         return E_INVALIDARG;
 
-    res = IStream_Read(pStm, &len, sizeof(ULONG), &got);
+    res = IStream_Read(pStm, &size, sizeof(ULONG), &got);
     if(SUCCEEDED(res)) {
         if(got == sizeof(ULONG)) {
             HeapFree(GetProcessHeap(), 0, This->URLName);
-            This->URLName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(len+1));
+            This->URLName=HeapAlloc(GetProcessHeap(),0,size);
             if(!This->URLName)
                 res = E_OUTOFMEMORY;
             else {
-                res = IStream_Read(pStm, This->URLName, len, NULL);
-                This->URLName[len] = 0;
+                res = IStream_Read(pStm, This->URLName, size, NULL);
+                This->URLName[size/sizeof(WCHAR) - 1] = 0;
             }
         }
         else
@@ -445,16 +445,16 @@ static HRESULT WINAPI URLMonikerImpl_Sav
     URLMonikerImpl *This = (URLMonikerImpl *)iface;
 
     HRESULT res;
-    ULONG len;
+    ULONG size;
     TRACE("(%p,%p,%d)\n",This,pStm,fClearDirty);
 
     if(!pStm)
         return E_INVALIDARG;
 
-    len = strlenW(This->URLName);
-    res=IStream_Write(pStm,&len,sizeof(ULONG),NULL);
+    size = (strlenW(This->URLName) + 1)*sizeof(WCHAR);
+    res=IStream_Write(pStm,&size,sizeof(ULONG),NULL);
     if(SUCCEEDED(res))
-        res=IStream_Write(pStm,This->URLName,len*sizeof(WCHAR),NULL);
+        res=IStream_Write(pStm,This->URLName,size,NULL);
     return res;
 
 }
@@ -472,8 +472,7 @@ static HRESULT WINAPI URLMonikerImpl_Get
     if(!pcbSize)
         return E_INVALIDARG;
 
-    pcbSize->u.LowPart = sizeof(ULONG) + (strlenW(This->URLName) * sizeof(WCHAR));
-    pcbSize->u.HighPart = 0;
+    pcbSize->QuadPart = sizeof(ULONG) + ((strlenW(This->URLName)+1) * sizeof(WCHAR));
     return S_OK;
 }
 


More information about the wine-patches mailing list