* rtl: fix TFPGList Add/Insert hang/crash (issue #15500)

git-svn-id: trunk@14718 -
This commit is contained in:
micha 2010-01-17 15:34:45 +00:00
parent 2c823f5935
commit 215823c88f

View File

@ -490,9 +490,13 @@ begin
if (Index < 0) or (Index > FCount) then
Error(SListIndexError, Index);
if FCount = FCapacity then Self.Expand;
if Index<FCount then
System.Move(InternalItems[Index]^, InternalItems[Index+1]^, (FCount - Index) * FItemSize);
Result := InternalItems[Index];
if Index<FCount then
begin
System.Move(Result^, (Result+FItemSize)^, (FCount - Index) * FItemSize);
{ clear for compiler assisted types }
System.FillByte(Result^, FItemSize, 0);
end;
Inc(FCount);
end;
@ -695,7 +699,7 @@ begin
if ResPtr <> nil then
Result := T(ResPtr^)
else
FillByte(Result, 0, sizeof(T));
FillByte(Result, sizeof(T), 0);
end;
function TFPGList.First: T;
@ -801,7 +805,7 @@ begin
if ResPtr <> nil then
Result := T(ResPtr^)
else
FillByte(Result, 0, sizeof(T));
FillByte(Result, sizeof(T), 0);
end;
function TFPGObjectList.First: T;
@ -898,7 +902,7 @@ begin
if ResPtr <> nil then
Result := T(ResPtr^)
else
FillByte(Result, 0, sizeof(T));
FillByte(Result, sizeof(T), 0);
end;
function TFPGInterfacedObjectList.First: T;