[php-src] PR #24205: ext/standard: Hold argv while getopt() converts its entries

From: Date: Thu, 08 Oct 2026 20:36:06 +0000
Subject: [php-src] PR #24205: ext/standard: Hold argv while getopt() converts its entries
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-39271@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/24205 Author: iliaal getopt() iterates $argv in place while converting each entry to a string, so a __toString() that modifies or unsets $argv resizes or frees the hash under the iteration; valgrind shows invalid reads in zif_getopt on 8.4. The array is now held for the duration of the loop, so such writes separate it, and the hold is released with GC_TRY_DTOR_NO_REF() so an unset $argv that is part of a cycle stays collectable. The long options array is passed by value, so it was already protected.

« previous php.git-pulls (#39271) next »