Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.5.7

- CLI:
. Fixed bug GH-21901 (Stale getopt() optional value). (onthebed)

- Opcache:
. Fixed tracing JIT crash when a VM interrupt is handled during an observed
user function call. (Levi Morrison)
Expand Down
3 changes: 3 additions & 0 deletions main/getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char
static char **prev_optarg = NULL;

php_optidx = -1;
if (optarg) {
*optarg = NULL;
}

if(prev_optarg && prev_optarg != optarg) {
/* reset the state */
Expand Down
13 changes: 13 additions & 0 deletions sapi/cli/tests/gh21901.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
Stale getopt() optional value in CLI
--FILE--
<?php
$php_escaped = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
$cmd = $php_escaped . ' -n -d foo=bar --ini';
echo shell_exec($cmd);
?>
--EXPECTF--
Configuration File (php.ini) Path: "%S"
Loaded Configuration File: "%S"
Scan for additional .ini files in: %s
Additional .ini files parsed: %s
Loading