Browse Source

* Avoid possible AV when the string-index is larger then the string-length

git-svn-id: trunk@16536 -
joost 14 years ago
parent
commit
af2ef60a29
1 changed files with 7 additions and 0 deletions
  1. 7 0
      packages/regexpr/src/regex.pp

+ 7 - 0
packages/regexpr/src/regex.pp

@@ -254,6 +254,13 @@ var
   pc : pchar;
   x:integer;
 begin
+  if Offset>length(S) then
+    begin
+    Result := False;
+    MatchPos := 0;
+    Exit;
+    end;
+
   {if the regex string hasn't been parsed yet, do so}
   if (FStateCount = 0) then begin
     if not Parse(ErrorPos, ErrorCode) then