From: jwalker7281 at yahoo dot com Operating system: Redhat Linux 9 PHP version: 5.0.0b4 (beta4) PHP Bug Type: Zend Engine 2 problem Bug description: Memory Leak with sscanf
Description: ------------ I found that using sscanf, at least within a foreach loop, leaks. The original code I found this in read in a file, and then did foreach( $lines as $line )... I wrote a small bit of code to simulate that. It doesn't give the same files for a leak location, but it still leaks. When running my code, I got this: /root/php-5.0.0b4/Zend/zend_execute.c(2973) : Freeing 0x40232D30 (2 bytes), script=./objtest /root/php-5.0.0b4/Zend/zend_variables.c(137) : Actual location (location was relayed) === Total 1 memory leaks detected === When running this test simulation code, I got this: /root/php-5.0.0b4/ext/standard/scanf.c(937) : Freeing 0x4022727C (4 bytes), script=./memleak === Total 1 memory leaks detected === Both are running PHP5, b4 in CLI mode. Reproduce code: --------------- #!/usr/local/bin/php -q <?php $strings = array( "#dude = me\n", "#bug = nasty\n" ); foreach( $strings as $string ) { sscanf( $string, "%s = %[^[]]", $var, $val ); echo "$var = $val\n"; } ?> Expected result: ---------------- It *works*, as in it outputs: ./memleak #dude = me #bug = nasty But it also gives that memory leak bug. Actual result: -------------- Please see above. -- Edit bug report at http://bugs.php.net/?id=27295&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27295&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27295&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=27295&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=27295&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=27295&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=27295&r=needscript Try newer version: http://bugs.php.net/fix.php?id=27295&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=27295&r=support Expected behavior: http://bugs.php.net/fix.php?id=27295&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=27295&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=27295&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=27295&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27295&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=27295&r=dst IIS Stability: http://bugs.php.net/fix.php?id=27295&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=27295&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=27295&r=float