1--TEST-- 2Bug #54350: Memory corruption with user_filter 3--FILE-- 4<?php 5 6class user_filter extends php_user_filter { 7 function filter($in, $out, &$consumed, $closing): int { 8 while ($bucket = stream_bucket_make_writeable($in)) { 9 } 10 fclose($this->stream); 11 return 0; 12 } 13} 14stream_filter_register('user_filter','user_filter'); 15$fd = fopen('php://memory','w'); 16$filter = stream_filter_append($fd, 'user_filter'); 17fwrite($fd, "foo"); 18 19?> 20--EXPECTF-- 21Warning: fclose(): 5 is not a valid stream resource in %s on line %d 22 23Warning: fclose(): supplied resource is not a valid stream resource in %s on line %d 24