Thought I might as well get these out of the tree and into peer-review land.... I wanted to check ILLoadFromStream on Windows, but my 98 dlls don't have it (it's ME or 2000+ only), and on my friends XP box, the VC++7 platform SDK didn't appear to have it. It seems the function used to be undocumented. ChangeLog: * GIT should not dereference ppv when unmarshalling interface * Restore use of refcounting in the GIT * IMallocSpy cannot cause an allocation failure when cb == 0 * Deal with the case of loading an empty PIDL from a stream better in ILLoadFromStream thanks -mike
Index: dlls/ole32/git.c =================================================================== RCS file: /home/wine/wine/dlls/ole32/git.c,v retrieving revision 1.4 diff -u -b -w -r1.4 git.c --- dlls/ole32/git.c 17 Jun 2003 03:57:18 -0000 1.4 +++ dlls/ole32/git.c 17 Jul 2003 11:01:06 -0000 @@ -107,8 +107,6 @@ void* StdGlobalInterfaceTable_Construct() { StdGlobalInterfaceTableImpl* newGIT; - TRACE("constructing\n"); - newGIT = HeapAlloc(GetProcessHeap(), 0, sizeof(StdGlobalInterfaceTableImpl)); if (newGIT == 0) return newGIT; @@ -128,6 +126,7 @@ FIXME("Revoke held interfaces here\n"); HeapFree(GetProcessHeap(), 0, self); + StdGlobalInterfaceTableInstance = NULL; } /*** @@ -169,7 +168,7 @@ } else return E_NOINTERFACE; /* Now inc the refcount */ - /* we don't use refcounts for now: StdGlobalInterfaceTable_AddRef(iface); */ + StdGlobalInterfaceTable_AddRef(iface); return S_OK; } @@ -261,9 +260,10 @@ entry = StdGlobalInterfaceTable_FindEntry(iface, dwCookie); if (entry == NULL) return E_INVALIDARG; if (!IsEqualIID(&entry->iid, &riid)) return E_INVALIDARG; + TRACE("entry=%p\n", entry); /* unmarshal the interface */ - hres = CoGetInterfaceAndReleaseStream(entry->stream, riid, *ppv); + hres = CoGetInterfaceAndReleaseStream(entry->stream, riid, ppv); if (hres) return hres; return S_OK; Index: dlls/ole32/ifs.c =================================================================== RCS file: /home/wine/wine/dlls/ole32/ifs.c,v retrieving revision 1.26 diff -u -b -w -r1.26 ifs.c --- dlls/ole32/ifs.c 10 Apr 2003 18:17:35 -0000 1.26 +++ dlls/ole32/ifs.c 17 Jul 2003 11:01:07 -0000 @@ -144,16 +144,18 @@ TRACE("(%ld)\n",cb); if(Malloc32.pSpy) { + DWORD preAllocResult; + EnterCriticalSection(&IMalloc32_SpyCS); - cb = IMallocSpy_PreAlloc(Malloc32.pSpy, cb); - if (0==cb) { - /* PreAlloc can force Alloc to fail */ + preAllocResult = IMallocSpy_PreAlloc(Malloc32.pSpy, cb); + if ((cb != 0) && (preAllocResult == 0)) { + /* PreAlloc can force Alloc to fail, but not if cb == 0 */ + TRACE("returning null\n"); LeaveCriticalSection(&IMalloc32_SpyCS); return NULL; } } - addr = HeapAlloc(GetProcessHeap(),0,cb); if(Malloc32.pSpy) { Index: dlls/shell32/pidl.c =================================================================== RCS file: /home/wine/wine/dlls/shell32/pidl.c,v retrieving revision 1.84 diff -u -b -w -r1.84 pidl.c --- dlls/shell32/pidl.c 19 May 2003 21:42:44 -0000 1.84 +++ dlls/shell32/pidl.c 17 Jul 2003 11:01:08 -0000 @@ -279,25 +279,35 @@ 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; + { + 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 - { SHFree(*ppPidl); + } 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; }