|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-02-18 14:42 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 02:00:01 2025 UTC |
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.