mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 21:39:18 +02:00
* patch by Rika + test: Don’t explicitly change GetMem(0) to GetMem(1), it works anyway, resolves #40456
This commit is contained in:
parent
6bdf9eb096
commit
4e1f854d49
@ -1075,11 +1075,7 @@ end;
|
|||||||
|
|
||||||
function SysGetMem(size : ptruint):pointer;
|
function SysGetMem(size : ptruint):pointer;
|
||||||
begin
|
begin
|
||||||
{ Something to allocate ? }
|
{ SysGetMem(0) is expected to return something freeable and non-nil. No need in explicit handling, presently. }
|
||||||
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;
|
|
||||||
{ calc to multiple of 16 after adding the needed bytes for memchunk header }
|
{ calc to multiple of 16 after adding the needed bytes for memchunk header }
|
||||||
if size <= (maxblocksize - sizeof(tmemchunk_fixed_hdr)) then
|
if size <= (maxblocksize - sizeof(tmemchunk_fixed_hdr)) then
|
||||||
begin
|
begin
|
||||||
|
8
tests/tbs/tb0710.pp
Normal file
8
tests/tbs/tb0710.pp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
var
|
||||||
|
p : pointer;
|
||||||
|
begin
|
||||||
|
p:=getmem(0);
|
||||||
|
if not(assigned(p)) then
|
||||||
|
halt(1);
|
||||||
|
freemem(p);
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user