IMallocSpy cannot cause an allocation failure when cb == 0.
This commit is contained in:
parent
72d8aa5ec2
commit
cb7db104dd
|
@ -144,16 +144,18 @@ static LPVOID WINAPI IMalloc_fnAlloc(LPMALLOC iface, DWORD cb) {
|
||||||
TRACE("(%ld)\n",cb);
|
TRACE("(%ld)\n",cb);
|
||||||
|
|
||||||
if(Malloc32.pSpy) {
|
if(Malloc32.pSpy) {
|
||||||
|
DWORD preAllocResult;
|
||||||
|
|
||||||
EnterCriticalSection(&IMalloc32_SpyCS);
|
EnterCriticalSection(&IMalloc32_SpyCS);
|
||||||
cb = IMallocSpy_PreAlloc(Malloc32.pSpy, cb);
|
preAllocResult = IMallocSpy_PreAlloc(Malloc32.pSpy, cb);
|
||||||
if (0==cb) {
|
if ((cb != 0) && (preAllocResult == 0)) {
|
||||||
/* PreAlloc can force Alloc to fail */
|
/* PreAlloc can force Alloc to fail, but not if cb == 0 */
|
||||||
|
TRACE("returning null\n");
|
||||||
LeaveCriticalSection(&IMalloc32_SpyCS);
|
LeaveCriticalSection(&IMalloc32_SpyCS);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
addr = HeapAlloc(GetProcessHeap(),0,cb);
|
addr = HeapAlloc(GetProcessHeap(),0,cb);
|
||||||
|
|
||||||
if(Malloc32.pSpy) {
|
if(Malloc32.pSpy) {
|
||||||
|
|
Loading…
Reference in New Issue