mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-25 18:59:11 +02:00
LazListClasses: fix overflow error
(cherry picked from commit c34dc52a82
)
This commit is contained in:
parent
c400834a6f
commit
cd560cc67d
@ -799,7 +799,7 @@ begin
|
|||||||
// use space at front of list
|
// use space at front of list
|
||||||
i := ACount;
|
i := ACount;
|
||||||
if (AIndex = Cnt) and (CntFreeFront-ACount > CntFreeEnd) then // move all entries;
|
if (AIndex = Cnt) and (CntFreeFront-ACount > CntFreeEnd) then // move all entries;
|
||||||
i := i + Max(Cardinal(CntFreeFront-ACount-CntFreeEnd) div 2 - 1, 0); // Make some room at the end of the list
|
i := i + Max(integer(Cardinal(CntFreeFront-ACount-CntFreeEnd) div 2) - 1, 0); // Make some room at the end of the list
|
||||||
|
|
||||||
PSource := FMem.FirstItemPointer;
|
PSource := FMem.FirstItemPointer;
|
||||||
PTarget := PSource - (i * FItemSize.ItemSize);
|
PTarget := PSource - (i * FItemSize.ItemSize);
|
||||||
@ -816,7 +816,7 @@ begin
|
|||||||
if CanEnd then begin
|
if CanEnd then begin
|
||||||
// use space at end of list
|
// use space at end of list
|
||||||
if (AIndex = 0) and (CntFreeEnd-ACount > CntFreeFront) then // move all entries;
|
if (AIndex = 0) and (CntFreeEnd-ACount > CntFreeFront) then // move all entries;
|
||||||
i := max(Cardinal(CntFreeEnd-ACount-CntFreeFront) div 2 - 1, 0) // Make some room at the end of the list
|
i := max(integer(Cardinal(CntFreeEnd-ACount-CntFreeFront) div 2) - 1, 0) // Make some room at the end of the list
|
||||||
else
|
else
|
||||||
i := 0;
|
i := 0;
|
||||||
|
|
||||||
@ -837,7 +837,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
// split to both ends
|
// split to both ends
|
||||||
assert((cap >= ACount) and (CntFreeFront> 0) and (CntFreeEnd > 0), 'TLazShiftBufferListObj.InsertRows: (cap >= ACount) and (CntFreeFront> 0) and (CntFreeEnd > 0)');
|
assert((cap >= ACount) and (CntFreeFront> 0) and (CntFreeEnd > 0), 'TLazShiftBufferListObj.InsertRows: (cap >= ACount) and (CntFreeFront> 0) and (CntFreeEnd > 0)');
|
||||||
i := Max(Cardinal(Cap-Cnt-ACount) div 2 - 1, 0);
|
i := Max(integer(Cardinal(Cap-Cnt-ACount) div 2) - 1, 0);
|
||||||
|
|
||||||
PSource := FMem.FirstItemPointer;
|
PSource := FMem.FirstItemPointer;
|
||||||
PTarget := PSource - ((CntFreeFront - i) * FItemSize.ItemSize);
|
PTarget := PSource - ((CntFreeFront - i) * FItemSize.ItemSize);
|
||||||
|
Loading…
Reference in New Issue
Block a user