Explorar el Código

* check length of optstring before dereferencing (optstring[1]) it. Fixes #40596

marcoonthegit hace 1 año
padre
commit
231007ebda
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1 1
      rtl/inc/getopts.pp

+ 1 - 1
rtl/inc/getopts.pp

@@ -409,7 +409,7 @@ begin
                    if opterr then
                     writeln(argv[0],': option ',pfound^.name,' requires an argument');
                    nextchar:=0;
-                   if optstring[1]=':' then
+                   if (length(optstring)>0) and (optstring[1]=':') then
                     Internal_getopt:=':'
                    else
                     Internal_getopt:='?';