|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-03-28 18:01 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 11:00:01 2025 UTC |
Description: ------------ It seems that stream function can cause memory leaks so easily. We hope the stream developer fix it as soon as possible. Here is another one: it leaks when you add ./configure --enable-debug Reproduce code: --------------- <?php class upper_filter extends php_user_filter{ function filter($in, $out, &$consumed, $closing) { while($bucket=stream_bucket_make_writeable($in)){ $fp=fopen("2.txt", "w"); $bucket=stream_bucket_new($fp, "Abc\n"); $bucket->data = strtoupper($bucket->data); $consumed += $bucket->datalen; stream_bucket_append($out, $bucket); } return PSFS_PASS_ON; } } stream_filter_register("upper", "upper_filter"); $fp=fopen("2.txt", "w"); stream_filter_append($fp, "upper"); fread($fp, 1024); fwrite($fp, "Thank you\n"); fclose($fp); readfile("2.txt"); unlink("2.txt"); ?> Actual result: -------------- [sqchen@localhost sqchen]$ $php tt.php ABC ~ [Tue Mar 28 16:54:43 2006] Script: 'tt.php' /home/sqchen/sqchen/php-5.1.2/main/streams/filter.c(129) : Freeing 0x083EE864 (10 bytes), script=tt.php [Tue Mar 28 16:54:43 2006] Script: 'tt.php' /home/sqchen/sqchen/php-5.1.2/main/streams/filter.c(126) : Freeing 0x083EE814 (32 bytes), script=tt.php === Total 2 memory leaks detected ===