mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 20:19:25 +02:00
* rtl: fix TFPGList Add/Insert hang/crash (issue #15500)
git-svn-id: trunk@14718 -
This commit is contained in:
parent
2c823f5935
commit
215823c88f
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user