diff --git a/.gitattributes b/.gitattributes index 27bd62dfc1..940ca57bbf 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10659,6 +10659,7 @@ tests/webtbs/tw17379a.pp svneol=native#text/plain tests/webtbs/tw17402.pp svneol=native#text/pascal tests/webtbs/tw17402a.pp svneol=native#text/pascal tests/webtbs/tw17413.pp svneol=native#text/plain +tests/webtbs/tw17430.pp svneol=native#text/plain tests/webtbs/tw1744.pp svneol=native#text/plain tests/webtbs/tw1754c.pp svneol=native#text/plain tests/webtbs/tw1755.pp svneol=native#text/plain diff --git a/rtl/inc/heap.inc b/rtl/inc/heap.inc index fed4c3e5cf..35edabd79d 100644 --- a/rtl/inc/heap.inc +++ b/rtl/inc/heap.inc @@ -970,6 +970,13 @@ var iter : cardinal; begin result:=nil; + { check for maximum possible allocation (everything is rounded up to the + next multiple of 64k) } + if (size>high(ptruint)-$ffff) then + if ReturnNilIfGrowHeapFails then + exit + else + HandleError(204); { free pending items } loc_freelists := @freelists; try_finish_waitvarlist(loc_freelists); diff --git a/tests/webtbs/tw17430.pp b/tests/webtbs/tw17430.pp new file mode 100644 index 0000000000..3884580cc0 --- /dev/null +++ b/tests/webtbs/tw17430.pp @@ -0,0 +1,12 @@ +program Project1; + +{$mode delphi}{$H+} + +var + p:pointer; +begin + returnnilifgrowheapfails:=true; + GetMem(p,ptruint(-128)); + if assigned(p) then + halt(1); +end.