Преглед на файлове

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

(cherry picked from commit 231007ebda4f6f8abce6655ebb04ba35632bfccb)
marcoonthegit преди 1 година
родител
ревизия
289ee2e406
променени са 1 файла, в които са добавени 1 реда и са изтрити 1 реда
  1. 1 1
      rtl/inc/getopts.pp

+ 1 - 1
rtl/inc/getopts.pp

@@ -407,7 +407,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:='?';