mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 23:01:11 +02:00
fixed mem leak and Index in TSynEditStringList.DeleteLines
git-svn-id: trunk@7400 -
This commit is contained in:
parent
653f20404a
commit
4e17e99aa8
@ -4897,7 +4897,7 @@ var
|
||||
Copy(Lines[BE.Y - 1], BE.X, MaxInt);
|
||||
// Delete all lines in the selection range.
|
||||
{begin} // djlp 2000-09-13
|
||||
TSynEditStringList(Lines).DeleteLines(BB.Y, BE.Y - BB.Y);
|
||||
TSynEditStringList(Lines).DeleteLines(BB.Y-1, BE.Y - BB.Y);
|
||||
// for x := BE.Y - 1 downto BB.Y do
|
||||
// Lines.Delete(x);
|
||||
{end} // djlp 2000-09-13
|
||||
|
@ -577,20 +577,26 @@ var
|
||||
{$ENDIF}
|
||||
begin
|
||||
if NumLines > 0 then begin
|
||||
if (Index < 0) or (Index > fCount) then
|
||||
if (Index < 0) or (Index >= fCount) then
|
||||
ListIndexOutOfBounds(Index);
|
||||
LinesAfter := fCount - (Index + NumLines - 1);
|
||||
LinesAfter := fCount - (Index + NumLines);
|
||||
if LinesAfter < 0 then
|
||||
NumLines := fCount - Index - 1;
|
||||
NumLines := fCount - Index;
|
||||
{$IFDEF FPC}
|
||||
// free the strings
|
||||
for i:=Index to Index+NumLines-1 do
|
||||
fList^[i].fString:='';
|
||||
{$ENDIF}
|
||||
if LinesAfter > 0 then begin
|
||||
BeginUpdate;
|
||||
try
|
||||
// move
|
||||
System.Move(fList^[Index + NumLines], fList^[Index],
|
||||
LinesAfter * SynEditStringRecSize);
|
||||
{$IFDEF FPC}
|
||||
// clear unused references
|
||||
FillChar(fList^[Index + LinesAfter], NumLines * SynEditStringRecSize,0);
|
||||
{$ENDIF}
|
||||
finally
|
||||
EndUpdate;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user