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

This commit is contained in:
marcoonthegit 2024-01-17 11:41:16 +01:00
parent 42f447257d
commit 231007ebda

View File

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