Author: fireball Date: Sun Oct 10 21:52:48 2010 New Revision: 49102
URL: http://svn.reactos.org/svn/reactos?rev=49102&view=rev Log: [HEAP] - 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).
Modified: trunk/reactos/dll/win32/kernel32/mem/heap.c
Modified: trunk/reactos/dll/win32/kernel32/mem/heap.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/mem/heap... ============================================================================== --- trunk/reactos/dll/win32/kernel32/mem/heap.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/mem/heap.c [iso-8859-1] Sun Oct 10 21:52:48 2010 @@ -13,6 +13,10 @@ #define NDEBUG #include <debug.h>
+/* TYPES *********************************************************************/ + +extern SYSTEM_BASIC_INFORMATION BaseCachedSysInfo; + /* FUNCTIONS ***************************************************************/
/* @@ -30,6 +34,17 @@ /* Remove non-Win32 flags and tag this allocation */ 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,