Deal with the case of loading an empty PIDL from a stream better in

ILLoadFromStream.
This commit is contained in:
Mike Hearn 2003-07-22 01:00:47 +00:00 committed by Alexandre Julliard
parent 0ab73312c8
commit 72d8aa5ec2
1 changed files with 20 additions and 10 deletions

View File

@ -279,25 +279,35 @@ HRESULT WINAPI ILLoadFromStream (IStream * pStream, LPITEMIDLIST * ppPidl)
IStream_AddRef (pStream);
if (SUCCEEDED(IStream_Read(pStream, (LPVOID)&wLen, 2, &dwBytesRead)))
{ *ppPidl = SHAlloc (wLen);
if (SUCCEEDED(IStream_Read(pStream, *ppPidl , wLen, &dwBytesRead)))
{ ret = S_OK;
}
else
{ SHFree(*ppPidl);
{
TRACE("PIDL length is %d\n", wLen);
if (wLen != 0) {
*ppPidl = SHAlloc (wLen);
if (SUCCEEDED(IStream_Read(pStream, *ppPidl , wLen, &dwBytesRead))) {
TRACE("Stream read OK\n");
ret = S_OK;
} else {
WARN("reading pidl failed\n");
SHFree(*ppPidl);
*ppPidl = NULL;
}
} else {
*ppPidl = NULL;
ret = S_OK;
}
}
/* we are not yet fully compatible */
if (!pcheck(*ppPidl))
{ SHFree(*ppPidl);
if (*ppPidl && !pcheck(*ppPidl))
{
WARN("Check failed\n");
SHFree(*ppPidl);
*ppPidl = NULL;
}
IStream_Release (pStream);
TRACE("done\n");
return ret;
}