* patch by Rika + test: Don’t explicitly change GetMem(0) to GetMem(1), it works anyway, resolves #40456

This commit is contained in:
florian 2024-03-01 22:49:18 +01:00
parent 6bdf9eb096
commit 4e1f854d49
2 changed files with 9 additions and 5 deletions

View File

@ -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

8
tests/tbs/tb0710.pp Normal file
View File

@ -0,0 +1,8 @@
var
p : pointer;
begin
p:=getmem(0);
if not(assigned(p)) then
halt(1);
freemem(p);
end.