ID: 34821
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
-Status: Open
+Status: Feedback
Bug Type: Zlib Related
Operating System: *
PHP Version: *
New Comment:
Do you have a patch?
Previous Comments:
------------------------------------------------------------------------
[2005-10-11 17:38:00] [EMAIL PROTECTED]
A possible fix would be to raise the size of the memory allocated by
default, e.g. adding 1% to the length of the incoming data instead of
0.1% additionally to some "safe" padding bytes.
------------------------------------------------------------------------
[2005-10-10 22:50:22] [EMAIL PROTECTED]
Description:
------------
Probably an edge case, but so nobody could claim I didn't report it ;)
It starts to fail with ~200k+.
Reproduce code:
---------------
<?php
$j = 200000;
$s = '';
srand(time());
for ($i = 0; $i < $j; ++$i) {
$s .= chr(rand(0,255));
}
gzencode($s); // fails with buffer error
$r = array();
echo "\nCharcode stats:\n";
for ($i = 0; $i < $j; ++$i) {
$x = ord($s{$i});
$r[$x] = isset($r[$x]) ? $r[$x]+1 : 1;
}
asort($r);
printf("MIN: %d -- AVG: %d -- MAX: %d\n", current($r),
array_sum($r)/count($r), end($r));
?>
Expected result:
----------------
No error
Actual result:
--------------
Warning: gzencode(): buffer error in
C:\Webserver\mike\zone\gzencode.php on line 10
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34821&edit=1