ID:               31478
 User updated by:  the_deppchef at hotmail dot com
-Summary:          SegFault/Memory Leak
 Reported By:      the_deppchef at hotmail dot com
 Status:           Open
 Bug Type:         Reproducible crash
 Operating System: Linux 2.4.27 (Debian)
 PHP Version:      5CVS-2005-01-10 (dev)
 New Comment:

forgot to put the name of the function in the summary, sorry :x


Previous Comments:
------------------------------------------------------------------------

[2005-01-10 22:55:24] the_deppchef at hotmail dot com

Description:
------------
Well, reading the manual about empty() you should think it checks
whether the given variable is set before it checks whether it is empty.

(Given example there: 
if (empty($var)) {
   echo '$var is either 0, empty, or not set at all';
})
However, when $var really is not set, i get a Memory Leak (in a big
script). I reduced the script to the code below and now even get a
Segmentation fault.

Reproduce code:
---------------
<?php
if(empty($foo)){
        echo 'empty';
}else{
        echo 'not empty';
}
?>

Expected result:
----------------
Echoing "empty" and nothing else.

Actual result:
--------------
Echoing "empty"
Valgrind says: http://tdc.medieval-wars.de/valgrind.txt.pid27963
Probably most important:
==27963== Process terminating with default action of signal 11
(SIGSEGV)
==27963==  Access not within mapped region at address 0xF45
==27963==    at 0x81EDD17: zend_execute_scripts
(/home/necmon/php5-200501101930/Zend/zend.c:1059)
==27963==    by 0x819E50D: php_execute_script
(/home/necmon/php5-200501101930/main/main.c:1636)
==27963==    by 0x8277DAE: main
(/home/necmon/php5-200501101930/sapi/cli/php_cli.c:944)

(Note: this does NOT only happen with the cli version!)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=31478&edit=1

Reply via email to