Jelajahi Sumber

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

florian 1 tahun lalu
induk
melakukan
4e1f854d49
2 mengubah file dengan 9 tambahan dan 5 penghapusan
  1. 1 5
      rtl/inc/heap.inc
  2. 8 0
      tests/tbs/tb0710.pp

+ 1 - 5
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

+ 8 - 0
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.