mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 10:20:21 +02:00
* tinyheap: Early check for very big requested mem sizes in order to prevent overflows and properly report the out of memory error.
git-svn-id: trunk@45844 -
This commit is contained in:
parent
c455e942e5
commit
6edbc9ed7e
@ -57,6 +57,7 @@
|
||||
|
||||
const
|
||||
TinyHeapMinBlock = sizeof(TTinyHeapBlock);
|
||||
TinyHeapMaxBlock = High(ptruint) - sizeof(TTinyHeapBlock) - sizeof(TTinyHeapMemBlockSize);
|
||||
|
||||
TinyHeapAllocGranularity = sizeof(TTinyHeapBlock);
|
||||
|
||||
@ -96,6 +97,8 @@
|
||||
{$ifdef DEBUG_TINY_HEAP}
|
||||
Write('SysGetMem(', Size, ')=');
|
||||
{$endif DEBUG_TINY_HEAP}
|
||||
if size>TinyHeapMaxBlock then
|
||||
HandleError(203);
|
||||
AllocSize := align(size+sizeof(TTinyHeapMemBlockSize), TinyHeapAllocGranularity);
|
||||
|
||||
p := FreeList;
|
||||
@ -320,6 +323,8 @@
|
||||
if (TTinyHeapPointerArithmeticType(p) < TTinyHeapPointerArithmeticType(HeapOrg)) or
|
||||
(TTinyHeapPointerArithmeticType(p) >= TTinyHeapPointerArithmeticType(HeapPtr)) then
|
||||
HandleError(204);
|
||||
if size>TinyHeapMaxBlock then
|
||||
HandleError(203);
|
||||
oldsize := FindSize(p);
|
||||
OldAllocSize := align(oldsize+sizeof(TTinyHeapMemBlockSize), TinyHeapAllocGranularity);
|
||||
NewAllocSize := align(size+sizeof(TTinyHeapMemBlockSize), TinyHeapAllocGranularity);
|
||||
|
Loading…
Reference in New Issue
Block a user