- Properly set HEAP_GROWABLE flag if dwMaximumSize is 0 in HeapCreate. Also check for dwMaximumSize validity. Fixes out-of-memory problems when running "heavy" applications like Office 2003 setup with a new heap manager (which actually respects HEAP_GROWABLE flag).

svn path=/trunk/; revision=49102
This commit is contained in:
Aleksey Bragin 2010-10-10 21:52:48 +00:00
parent e45344cae1
commit b00e93abd1

View file

@ -13,6 +13,10 @@
#define NDEBUG
#include <debug.h>
/* TYPES *********************************************************************/
extern SYSTEM_BASIC_INFORMATION BaseCachedSysInfo;
/* FUNCTIONS ***************************************************************/
/*
@ -31,6 +35,17 @@ HeapCreate(DWORD flOptions,
Flags = (flOptions & (HEAP_GENERATE_EXCEPTIONS | HEAP_NO_SERIALIZE)) |
HEAP_CLASS_1;
/* Check if heap is growable and ensure max size is correct */
if (dwMaximumSize == 0)
Flags |= HEAP_GROWABLE;
else if (dwMaximumSize < BaseCachedSysInfo.PageSize &&
dwInitialSize > dwMaximumSize)
{
/* Max size is non-zero but less than page size which can't be correct.
Fix it up by bumping it to the initial size whatever it is. */
dwMaximumSize = dwInitialSize;
}
/* Call RTL Heap */
hRet = RtlCreateHeap(Flags,
NULL,