diff --git a/rtl/inc/heap.inc b/rtl/inc/heap.inc index 4f0cbaf5df..5d6c0cfe65 100644 --- a/rtl/inc/heap.inc +++ b/rtl/inc/heap.inc @@ -1066,7 +1066,10 @@ var pcurrsize: ptrint; begin if p=nil then - exit; + begin + result:=0; + exit; + end; pcurrsize := pmemchunk_fixed(p-sizeof(tmemchunk_fixed_hdr))^.size; { check if this is a fixed- or var-sized chunk } if (pcurrsize and fixedsizeflag) = 0 then @@ -1088,14 +1091,14 @@ var pcurrsize: ptrint; begin SysFreeMemSize := 0; + if p=nil then + exit; if size<=0 then begin if size<0 then HandleError(204); exit; end; - if p=nil then - HandleError(204); pcurrsize := pmemchunk_fixed(p-sizeof(tmemchunk_fixed_hdr))^.size; { check if this is a fixed- or var-sized chunk } diff --git a/rtl/inc/heaptrc.pp b/rtl/inc/heaptrc.pp index b0ce58e9c5..fe470c8917 100644 --- a/rtl/inc/heaptrc.pp +++ b/rtl/inc/heaptrc.pp @@ -433,6 +433,11 @@ var {$endif} extra_size : ptrint; begin + if p=nil then + begin + TraceFreeMemSize:=0; + exit; + end; inc(freemem_size,size); inc(freemem8_size,((size+7) div 8)*8); pp:=pheap_mem_info(p-sizeof(theap_mem_info)); @@ -554,6 +559,11 @@ var l : ptrint; pp : pheap_mem_info; begin + if p=nil then + begin + TraceFreeMem:=0; + exit; + end; pp:=pheap_mem_info(p-sizeof(theap_mem_info)); l:=SysMemSize(pp); dec(l,sizeof(theap_mem_info)+pp^.extra_info_size);