LCL: TTextStrings: fixed uninitialized memory, bug #24773

git-svn-id: trunk@42187 -
This commit is contained in:
mattias 2013-07-23 22:04:30 +00:00
parent 31d427c439
commit eae2765bb9

View File

@ -386,6 +386,7 @@ begin
if Index<FLineCount then begin
System.Move(FLineRanges[Index],FLineRanges[Index+1],
(FLineCount-Index)*SizeOf(TTextLineRange));
FillByte(FLineRanges[Index],SizeOf(TTextLineRange),0);
for i:=Index+1 to FLineCount do begin
inc(FLineRanges[i].StartPos,NewLineLen);
inc(FLineRanges[i].EndPos,NewLineLen);
@ -424,7 +425,7 @@ begin
dec(FLineRanges[i].EndPos,OldLineLen);
end;
end;
// clear last element (this helps finding bugs)
// clear last element
FillByte(FLineRanges[FLineCount],SizeOf(TTextLineRange),0);
end;
@ -540,6 +541,7 @@ var
i: LongInt;
Obj: TObject;
LineShortLen: LongInt;
Line: PTextLineRange;
begin
// check values
if CurIndex=NewIndex then exit;
@ -585,10 +587,11 @@ begin
// put current line at new position
i:=SrcPos3-LineLen;
System.Move(LineStr[1],FText[i],LineLen);
FLineRanges[NewIndex].StartPos:=i;
FLineRanges[NewIndex].EndPos:=i+LineShortLen;
FLineRanges[NewIndex].Line:=''; // this will be updated on demand
FLineRanges[NewIndex].TheObject:=Obj;
Line:=@FLineRanges[NewIndex];
Line^.StartPos:=i;
Line^.EndPos:=i+LineShortLen;
Pointer(Line^.Line):=nil; // this will be updated on demand, see Get
Line^.TheObject:=Obj;
end else begin
// move to lower index
if (CurIndex=FLineCount-1) and (FLineRanges[CurIndex].EndPos>length(FText))
@ -616,10 +619,11 @@ begin
SizeOf(TTextLineRange)*(CurIndex-NewIndex));
// put current line at new position
System.Move(LineStr[1],FText[SrcPos1],LineLen);
FLineRanges[NewIndex].StartPos:=SrcPos1;
FLineRanges[NewIndex].EndPos:=SrcPos1+LineShortLen;
FLineRanges[NewIndex].Line:=''; // this will be updated on demand
FLineRanges[NewIndex].TheObject:=Obj;
Line:=@FLineRanges[NewIndex];
Line^.StartPos:=SrcPos1;
Line^.EndPos:=SrcPos1+LineShortLen;
Pointer(Line^.Line):=nil; // this will be updated on demand, see Get
Line^.TheObject:=Obj;
end;
end;