* Observe max capacity. Resolves issue #40720

This commit is contained in:
Michael Van Canneyt 2024-03-30 11:23:42 +01:00
parent e42209457e
commit c17cbbe788

View File

@ -684,6 +684,11 @@ begin
if FCapacity > 3 then IncSize := IncSize + 4;
if FCapacity > 8 then IncSize := IncSize + 8;
if FCapacity > 127 then Inc(IncSize, FCapacity shr 2);
if FCapacity+IncSize>MaxListSize then
IncSize:=MaxListSize-FCapacity;
// If we were at max capacity already, force error.
If IncSize<=0 then
IncSize:=1; // Will trigger error
SetCapacity(FCapacity + IncSize);
Result := Self;
end;