Revert r33057. MaxLen is the maximum value that Pos can return and does not need to be adjusted by (Offset - 1). Also there's no buffer that could be overrun as i is not used to access the string's buffer. Fixes failure of tests/test/units/system/tstring.pp

git-svn-id: trunk@33089 -
This commit is contained in:
svenbarth 2016-02-12 16:07:26 +00:00
parent e23ed15634
commit 77cb13c38c

View File

@ -586,7 +586,7 @@ begin
Pos:=0;
if (Length(SubStr)>0) and (Offset>0) and (Offset<Length(Source)) then
begin
MaxLen:=Length(source)-Length(SubStr)-(OffSet-1);
MaxLen:=Length(source)-Length(SubStr);
i:=Offset-1;
pc:=@source[Offset];
while (i<=MaxLen) do