diff --git a/rtl/objpas/sysstr.inc b/rtl/objpas/sysstr.inc index e278c52a22..dc667ca95b 100644 --- a/rtl/objpas/sysstr.inc +++ b/rtl/objpas/sysstr.inc @@ -608,9 +608,10 @@ Var ChPos,OldPos,ArgPos,DoArg,Len : Longint; begin If Value<>-1 then exit; // Was already read. OldPos:=chPos; - While (Chpos0) do inc(chpos); - If Chpos=len then DoFormatError(feInvalidFormat); + If Chpos>len then + DoFormatError(feInvalidFormat); If Fmt[Chpos]='*' then begin If (Chpos>OldPos) or (ArgPos>High(Args)) @@ -741,14 +742,14 @@ Const Zero = '000000000000000000000000000000000000000000000000000000000000000'; begin Result:=''; - Len:=Length(Fmt)+1; + Len:=Length(Fmt); Chpos:=1; OldPos:=1; ArgPos:=0; - While chpos'%') do inc(chpos); + While (ChPos<=Len) and (Fmt[chpos]<>'%') do + inc(chpos); If ChPos>OldPos Then Result:=Result+Copy(Fmt,OldPos,Chpos-Oldpos); If ChPos