소스 검색

* 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:='?';