ID: 19943 Updated by: [EMAIL PROTECTED] Reported By: su-php at bossi dot com -Status: Verified +Status: Closed Bug Type: Scripting Engine problem Operating System: Win2K PHP Version: 4.3.2-dev New Comment:
Memleak fixed in CVS. Previous Comments: ------------------------------------------------------------------------ [2003-02-25 02:46:58] [EMAIL PROTECTED] Memleak still present in 4.3.2-dev. ------------------------------------------------------------------------ [2002-11-05 13:40:16] [EMAIL PROTECTED] The reported behaviour itself is not a bug (see http://lists.php.net/article.php?group=php.dev&article=90522 for detail), but the memory leaks imply another bug. So I decided to reclassify this as Scripting Engine problem, and change the status to "Analyzed". Anyway thank you for the bug report! -- Moriyoshi ------------------------------------------------------------------------ [2002-10-30 07:30:05] Ppslim at ntlworld dot com I think this is pretty much invalid. [EMAIL PROTECTED] posted 2 examples. Only 1 is correct, or infact, valid code. In the first example, you have the following 2 array assignments. $ragged[$count] = 'single '.$count; $ragged[$count]['idx'] = 'ragged '.$count; In this, you assign a string to $ragged[$count], then, you turn it into an array using $regged[$count]['idx']. This is invlaid in most languages. In the $ragged[$count], $ragged['idx'][$count] method, no type changes are taking place. ------------------------------------------------------------------------ [2002-10-16 22:51:14] [EMAIL PROTECTED] A pretty interesting bug this is, there appear to be 2 possible behaviours that can happen here and only 1 is correct. <?php $ar = array(); for ( $count = 0; $count < 10; $count++ ) { $ar[$count] = "$count"; $ar[$count]['idx'] = "$count"; } for ( $count = 0; $count < 10; $count++ ) { echo $ar[$count]." -- ".$ar[$count]['idx']."\n"; } ?> The code above will output: t 0 -- t t 1 -- t t 2 -- t t 3 -- t t 4 -- t t 5 -- t t 6 -- t t 7 -- t t 8 -- t t 9 -- t /home/rei/PHP_CVS/php4/Zend/zend_operators.c(1008) : Freeing 0x08369384 (6 bytes), script=a.php Last leak repeated 9 times If the " around the $count variable are removed then the script reports: Warning: Cannot use a scalar value as an array in /home/rei/PHP_CVS/php4/a.php on line 7 /home/rei/PHP_CVS/php4/a.php(7) : Warning - Cannot use a scalar value as an array for every assignment and does no initialize any of the $ar[$count]['idx'] values. ------------------------------------------------------------------------ [2002-10-16 19:54:16] su-php at bossi dot com However, the following codes does work, even though the array is still ragged: <? $ragged = array(); for ( $count = 0; $count < 10; $count++ ) { $ragged['idx'][$count] = 'ragged '.$count; $ragged[$count] = 'single '.$count; } ?> <html><head></head><body> <table border="1"> <tr> <td>Expected</td><td>Actual</td> <td>Expected IDX</td><td>Actual IDX</td> </tr> <? for ( $count = 0; $count < 10; $count++ ) { ?> <tr> <td> <?= 'single '.$count ?> </td><td> <?= $ragged[$count] ?> </td> <td> <?= 'ragged '.$count ?> </td><td> <?= $ragged['idx'][$count] ?> </td> </tr> <? } ?> </table></body></html> ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/19943 -- Edit this bug report at http://bugs.php.net/?id=19943&edit=1