|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-03-18 19:56 UTC] leon at struktur dot de
Description: ------------ COPY FROM : https://bugs.php.net/bug.php?id=45392 STILL NOT FIXED, BUT BUG IS CLOSED !! When memory_limit is reached, and one is using the output buffering functions, instead of just dying with an "out of memory" error, the contents of the buffer are spilled onto stdout. The output_buffering ini setting wasn't set to any particular limit. Test script: --------------- <?php ob_start(); $i = 0; while($i++ < 10000000) { echo str_repeat("lol", 42); } ob_end_clean(); /*Note that the 10,000,000 number varies according to your memory_limit*/ Expected result: ---------------- STDERR: Fatal error: Allowed memory size of 134217728 bytes exhausted at /home/flebron/cvs/php/php5.3-200806291230/main/output.c:395 (tried to allocate 133693441 bytes) in /home/flebron/cvs/php/ob.php on line 5 Actual result: -------------- STDERR: Fatal error: Allowed memory size of 134217728 bytes exhausted at /home/flebron/cvs/php/php5.3-200806291230/main/output.c:395 (tried to allocate 133693441 bytes) in /home/flebron/cvs/php/ob.php on line 5 STDOUT: The text in the buffer is printed to stdout (millions of "lolol"s). PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 15:00:02 2025 UTC |
New test script: $img = @imagecreatefromstring(file_get_contents($file)); if($img !== false) { imagealphablending($img, false); imagesavealpha($img, true); ob_start(); imagepng($img); $img_content = ob_get_clean(); imagedestroy($img); $img_content = base64_encode($img_content); return $img_content; } Output: "* PNG IHDR**" New test #2 script: $img = @imagecreatefromstring(file_get_contents($file)); if($img !== false) { imagealphablending($img, false); imagesavealpha($img, true); ob_start(); echo 'LALALA'; imagepng($img); $img_content = ob_get_clean(); imagedestroy($img); $img_content = base64_encode($img_content); return $img_content; } Output: "LALALA* PNG IHDR**" BTW: It works (I get no output) when I add ini_set('memory_limit', '-1');[yohgaki@dev PHP-5.5]$ cat t.php <?php ob_start(); $i = 0; while($i++ < 1024*4) { echo str_repeat("a", 1024); } ob_end_clean(); ?> END [yohgaki@dev PHP-5.5]$ ./php-bin -d error_reporting=-1 -d memory_limit=400000 t.php Fatal error: Allowed memory size of 400000 bytes exhausted at /home/yohgaki/git/oss/php.net/PHP-5.5/Zend/zend_stack.c:37 (tried to allocate 512 bytes) in /home/yohgaki/workspace/ext/git/oss/php.net/PHP-5.5/t.php on line 4 It seems working correctly. Are you sure you have reached memory_limit?[yohgaki@dev PHP-5.5]$ cat t.php <?php ob_start(); $i = 0; while($i++ < 1024*4) { echo str_repeat("a", 1024); } ob_end_clean(); ?> END [yohgaki@dev PHP-5.5]$ ./php-bin -d error_reporting=-1 -d memory_limit=400000 t.php Fatal error: Allowed memory size of 400000 bytes exhausted at /home/yohgaki/git/oss/php.net/PHP-5.5/Zend/zend_stack.c:37 (tried to allocate 512 bytes) in /home/yohgaki/workspace/ext/git/oss/php.net/PHP-5.5/t.php on line 4 It seems working correctly. Are you sure you have reached memory_limit?