LCL: TTextStrings: check Index out of bounds

git-svn-id: trunk@42186 -
This commit is contained in:
mattias 2013-07-23 21:46:48 +00:00
parent 08bdff7239
commit 31d427c439

View File

@ -199,9 +199,11 @@ end;
function TTextStrings.GetObject(Index: Integer): TObject; function TTextStrings.GetObject(Index: Integer): TObject;
begin begin
if FArraysValid then if FArraysValid then begin
Result:=FLineRanges[Index].TheObject if (Index<0) or (Index>=FLineCount) then
else Error(rsListIndexExceedsBounds, Index);
Result:=FLineRanges[Index].TheObject;
end else
Result:=nil; Result:=nil;
end; end;
@ -217,6 +219,8 @@ var
NewEndPos: Integer; NewEndPos: Integer;
begin begin
if not FArraysValid then BuildArrays; if not FArraysValid then BuildArrays;
if (Index<0) or (Index>=FLineCount) then
Error(rsListIndexExceedsBounds, Index);
OldStartPos:=FLineRanges[Index].StartPos; OldStartPos:=FLineRanges[Index].StartPos;
OldEndPos:=FLineRanges[Index].EndPos; OldEndPos:=FLineRanges[Index].EndPos;
NewLineLen:=length(s); NewLineLen:=length(s);
@ -256,6 +260,8 @@ end;
procedure TTextStrings.PutObject(Index: Integer; AnObject: TObject); procedure TTextStrings.PutObject(Index: Integer; AnObject: TObject);
begin begin
if not FArraysValid then BuildArrays; if not FArraysValid then BuildArrays;
if (Index<0) or (Index>=FLineCount) then
Error(rsListIndexExceedsBounds, Index);
FLineRanges[Index].TheObject:=AnObject; FLineRanges[Index].TheObject:=AnObject;
end; end;
@ -399,6 +405,8 @@ var
i: Integer; i: Integer;
begin begin
if not FArraysValid then BuildArrays; if not FArraysValid then BuildArrays;
if (Index<0) or (Index>=FLineCount) then
Error(rsListIndexExceedsBounds, Index);
// adjust text // adjust text
OldLineLen:=GetLineLen(Index,true); OldLineLen:=GetLineLen(Index,true);
if OldLineLen>0 then begin if OldLineLen>0 then begin