Browse Source

* Fix result of TFPSList.Expand in case of early exit

Michaël Van Canneyt 1 year ago
parent
commit
6689e2fe21
1 changed files with 3 additions and 2 deletions
  1. 3 2
      rtl/objpas/fgl.pp

+ 3 - 2
rtl/objpas/fgl.pp

@@ -679,7 +679,9 @@ function TFPSList.Expand: TFPSList;
 var
 var
   IncSize : Longint;
   IncSize : Longint;
 begin
 begin
-  if FCount < FCapacity then exit;
+  Result := Self;
+  if FCount < FCapacity then 
+    exit;
   if FCapacity > 127 then 
   if FCapacity > 127 then 
     IncSize:=FCapacity shr 2
     IncSize:=FCapacity shr 2
   else if FCapacity > 8 then 
   else if FCapacity > 8 then 
@@ -692,7 +694,6 @@ begin
   If IncSize<=0 then
   If IncSize<=0 then
     IncSize:=1; // Will trigger error 
     IncSize:=1; // Will trigger error 
   SetCapacity(FCapacity + IncSize);
   SetCapacity(FCapacity + IncSize);
-  Result := Self;
 end;
 end;
 
 
 function TFPSList.GetFirst: Pointer;
 function TFPSList.GetFirst: Pointer;