Browse Source

Make sure that we do not read passed the end of OPTSTRING variable

git-svn-id: trunk@45736 -
pierre 5 years ago
parent
commit
60c187e169
1 changed files with 2 additions and 2 deletions
  1. 2 2
      rtl/inc/getopts.pp

+ 2 - 2
rtl/inc/getopts.pp

@@ -460,8 +460,8 @@ begin
      exit;
    end;
   Internal_getopt:=optstring[temp];
-  if optstring[temp+1]=':' then
-   if optstring[temp+2]=':' then
+  if (length(optstring)>temp) and (optstring[temp+1]=':') then
+   if (length(optstring)>temp+1) and (optstring[temp+2]=':') then
     begin { optional argument }
       if nextchar>0 then
        begin