Skip to content

Commit 33cdf36

Browse files
committed
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
1 parent 46352f7 commit 33cdf36

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ PHP NEWS
2929
filegroup(), fileatime(), filemtime(), filectime(), filetype(),
3030
is_writable(), is_readable(), is_executable(), is_file(), is_dir(),
3131
is_link(), file_exists(), lstat(), stat(). (Girgias)
32+
. Fixed bug GH-22818 (stream_filter_register() orphaned user_filter_map on
33+
shutdown re-registration). (David Carlier)
3234

3335
30 Jul 2026, PHP 8.6.0alpha3
3436

ext/standard/user_filters.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,9 @@ PHP_FUNCTION(stream_filter_register)
613613
zend_hash_init(BG(user_filter_map), 8, NULL, NULL, 0);
614614
}
615615

616-
/* The factory has just been (re)registered, so keep the map in sync. */
617-
zend_hash_update_ptr(BG(user_filter_map), filtername, ce);
616+
/* The factory registration above already rejected a duplicate name, so the
617+
* filter name cannot be present in the map either. */
618+
zend_hash_add_new_ptr(BG(user_filter_map), filtername, ce);
618619

619620
RETURN_TRUE;
620621
}

0 commit comments

Comments
 (0)