From 4e1f854d49059d8eabd0e39d526a58dcdaec81b4 Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 1 Mar 2024 22:49:18 +0100 Subject: [PATCH] =?UTF-8?q?=20=20*=20patch=20by=20Rika=20+=20test:=20Don?= =?UTF-8?q?=E2=80=99t=20explicitly=20change=20GetMem(0)=20to=20GetMem(1),?= =?UTF-8?q?=20it=20works=20anyway,=20resolves=20#40456?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rtl/inc/heap.inc | 6 +----- tests/tbs/tb0710.pp | 8 ++++++++ 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 tests/tbs/tb0710.pp diff --git a/rtl/inc/heap.inc b/rtl/inc/heap.inc index 4dae1fb475..dfb05cd75e 100644 --- a/rtl/inc/heap.inc +++ b/rtl/inc/heap.inc @@ -1075,11 +1075,7 @@ end; function SysGetMem(size : ptruint):pointer; begin -{ Something to allocate ? } - if size=0 then - { we always need to allocate something, using heapend is not possible, - because heappend can be changed by growheap (PFV) } - size := 1; +{ SysGetMem(0) is expected to return something freeable and non-nil. No need in explicit handling, presently. } { calc to multiple of 16 after adding the needed bytes for memchunk header } if size <= (maxblocksize - sizeof(tmemchunk_fixed_hdr)) then begin diff --git a/tests/tbs/tb0710.pp b/tests/tbs/tb0710.pp new file mode 100644 index 0000000000..cac2e57024 --- /dev/null +++ b/tests/tbs/tb0710.pp @@ -0,0 +1,8 @@ +var + p : pointer; +begin + p:=getmem(0); + if not(assigned(p)) then + halt(1); + freemem(p); +end.