mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 22:06:40 +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
|
if (Index < 0) or (Index > FCount) then
|
||||||
Error(SListIndexError, Index);
|
Error(SListIndexError, Index);
|
||||||
if FCount = FCapacity then Self.Expand;
|
if FCount = FCapacity then Self.Expand;
|
||||||
if Index<FCount then
|
|
||||||
System.Move(InternalItems[Index]^, InternalItems[Index+1]^, (FCount - Index) * FItemSize);
|
|
||||||
Result := InternalItems[Index];
|
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);
|
Inc(FCount);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -695,7 +699,7 @@ begin
|
|||||||
if ResPtr <> nil then
|
if ResPtr <> nil then
|
||||||
Result := T(ResPtr^)
|
Result := T(ResPtr^)
|
||||||
else
|
else
|
||||||
FillByte(Result, 0, sizeof(T));
|
FillByte(Result, sizeof(T), 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFPGList.First: T;
|
function TFPGList.First: T;
|
||||||
@ -801,7 +805,7 @@ begin
|
|||||||
if ResPtr <> nil then
|
if ResPtr <> nil then
|
||||||
Result := T(ResPtr^)
|
Result := T(ResPtr^)
|
||||||
else
|
else
|
||||||
FillByte(Result, 0, sizeof(T));
|
FillByte(Result, sizeof(T), 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFPGObjectList.First: T;
|
function TFPGObjectList.First: T;
|
||||||
@ -898,7 +902,7 @@ begin
|
|||||||
if ResPtr <> nil then
|
if ResPtr <> nil then
|
||||||
Result := T(ResPtr^)
|
Result := T(ResPtr^)
|
||||||
else
|
else
|
||||||
FillByte(Result, 0, sizeof(T));
|
FillByte(Result, sizeof(T), 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFPGInterfacedObjectList.First: T;
|
function TFPGInterfacedObjectList.First: T;
|
||||||
|
Loading…
Reference in New Issue
Block a user