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.
This commit is contained in:
parent
d76a15a36d
commit
d82c456e5f
|
@ -410,23 +410,23 @@ static HRESULT WINAPI URLMonikerImpl_Load(IMoniker* iface,IStream* pStm)
|
|||
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_Save(IMoniker* iface,
|
|||
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_GetSizeMax(IMoniker* iface,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue