[php-src] master: Use zend_hash_add_new_ptr() for the user_filter_map insertion.

From: Date: Sun, 02 Aug 2026 20:32:44 +0000
Subject: [php-src] master: Use zend_hash_add_new_ptr() for the user_filter_map insertion.
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-140415@lists.php.net to get a copy of this message
Author: David Carlier (devnexen) Date: 2026-08-02T21:32:11+01:00 Commit: https://github.com/php/php-src/commit/33cdf36326319995a973d6009c0df34dcdc76292 Raw diff: https://github.com/php/php-src/commit/33cdf36326319995a973d6009c0df34dcdc76292.diff Use zend_hash_add_new_ptr() for the user_filter_map insertion. The volatile factory registration above already rejects a duplicate filter name, so the name cannot be in the map either. The add_new variant asserts that invariant in debug builds. Close GH-22838 Changed paths: M NEWS M ext/standard/user_filters.c Diff: diff --git a/NEWS b/NEWS index 425a48481a98..4e95bed34c84 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,8 @@ PHP NEWS filegroup(), fileatime(), filemtime(), filectime(), filetype(), is_writable(), is_readable(), is_executable(), is_file(), is_dir(), is_link(), file_exists(), lstat(), stat(). (Girgias) + . Fixed bug GH-22818 (stream_filter_register() orphaned user_filter_map on + shutdown re-registration). (David Carlier) 30 Jul 2026, PHP 8.6.0alpha3 diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index d69af26912cc..e65ddd78ba4d 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -613,8 +613,9 @@ PHP_FUNCTION(stream_filter_register) zend_hash_init(BG(user_filter_map), 8, NULL, NULL, 0); } - /* The factory has just been (re)registered, so keep the map in sync. */ - zend_hash_update_ptr(BG(user_filter_map), filtername, ce); + /* The factory registration above already rejected a duplicate name, so the + * filter name cannot be present in the map either. */ + zend_hash_add_new_ptr(BG(user_filter_map), filtername, ce); RETURN_TRUE; }

« previous php.cvs (#140415) next »