Skip to content
Open
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
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ PHP NEWS
is_writable(), is_readable(), is_executable(), is_file(), is_dir(),
is_link(), file_exists(), lstat(), stat(). (Girgias)

- Streams:
. Fixed memory leaks when a user stream filter returns PSFS_PASS_ON without
processing all input buckets. (Matthias Goergens)

30 Jul 2026, PHP 8.6.0alpha3

- Core:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
stream_filter_register() with a class that coerces the $consumed parameter of filter method
--XFAIL--
This leaks memory
--FILE--
<?php

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ var_dump(stream_filter_append(STDOUT, "invalid_filter"));
$out = fwrite(STDOUT, "Hello\n");
var_dump($out);

$stream = fopen('data://text/plain,Hello', 'r');
var_dump(stream_filter_append($stream, "invalid_filter"));
var_dump(stream_get_contents($stream));

?>
--EXPECTF--
bool(true)
resource(4) of type (stream filter)

Warning: fwrite(): Unprocessed filter buckets remaining on input brigade in %s on line %d
int(0)
resource(%d) of type (stream filter)

Warning: stream_get_contents(): Unprocessed filter buckets remaining on input brigade in %s on line %d
string(0) ""
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
stream_filter_register() with a class name exist that mocks php_user_filter with a filter method
--XFAIL--
This leaks memory
--FILE--
<?php

Expand Down
5 changes: 5 additions & 0 deletions ext/standard/user_filters.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ static php_stream_filter_status_t userfilter_filter(

if (buckets_in->head) {
php_error_docref(NULL, E_WARNING, "Unprocessed filter buckets remaining on input brigade");
php_stream_bucket *bucket;
while ((bucket = buckets_in->head)) {
php_stream_bucket_unlink(bucket);
php_stream_bucket_delref(bucket);
}
}

/* filter resources are cleaned up by the stream destructor,
Expand Down
Loading