Browse Source

* wrap getfirst and getlast in fcount<>0 because otherwise it will dereference nil.
Mantis #30080

git-svn-id: trunk@33598 -

marco 9 years ago
parent
commit
d4fd7520ef
1 changed files with 8 additions and 2 deletions
  1. 8 2
      rtl/objpas/fgl.pp

+ 8 - 2
rtl/objpas/fgl.pp

@@ -876,7 +876,10 @@ end;
 
 
 function TFPGList.GetFirst: T;
 function TFPGList.GetFirst: T;
 begin
 begin
-  Result := T(inherited GetFirst^);
+  if FCount<>0 then
+    Result := T(inherited GetFirst^)
+  else
+    Result:=Default(T);
 end;
 end;
 
 
 procedure TFPGList.SetFirst(const Value: T);
 procedure TFPGList.SetFirst(const Value: T);
@@ -906,7 +909,10 @@ end;
 
 
 function TFPGList.GetLast: T;
 function TFPGList.GetLast: T;
 begin
 begin
-  Result := T(inherited GetLast^);
+  if FCount<>0 then
+    Result := T(inherited GetLast^)
+  else
+    result:=Default(T);
 end;
 end;
 
 
 procedure TFPGList.SetLast(const Value: T);
 procedure TFPGList.SetLast(const Value: T);