codetools: h2p: added safety check

git-svn-id: trunk@14660 -
This commit is contained in:
mattias 2008-03-26 17:52:58 +00:00
parent dce2481e79
commit fc6e52e515

View File

@ -410,10 +410,11 @@ begin
{$R-}
Result:=Source;
DstPos:=1;
SrcPos:=1;
SrcPos:=StartPos;
SrcLen:=length(Source);
if EndPos<1 then EndPos:=SrcLen+1;
if SrcLen>EndPos then SrcLen:=EndPos;
if EndPos>SrcLen then EndPos:=SrcLen+1;
if SrcPos<EndPos then begin
repeat
ReadRawNextCAtom(Source,SrcPos,AtomStart);
if AtomStart>=EndPos then break;
@ -432,6 +433,9 @@ begin
end;
end;
until false;
end;
if DstPos>length(Result)+1 then
raise Exception.Create('');
SetLength(Result,DstPos-1);
{$IFDEF RangeChecking}{$R+}{$UNDEF RangeChecking}{$ENDIF}
end;