|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-06-28 03:26 UTC] khagiya1 at yahoo dot co dot jp
Description:
------------
When __set is called to the class by which the overload was carried out,
operation by FOO and constant ('FOO') is different.
Reproduce code:
---------------
<?php
define( 'FOO', 'BAR' );
class line
{
var $_data = array();
function set( $key, $value )
{
$this->_data[$key] = $value;
}
function get( $key )
{
return $this->_data[$key];
}
}
class Info
{
var $_data = null;
function Info( & $line )
{
$this->_data = array( & $line );
}
function __set( $key, $value )
{
$data =& $this->_data;
$data[0]->set( $key, $value );
return TRUE;
}
function __get( $key, &$value )
{
$data = $this->_data;
$ret =& $data[0]->get( $key );
$value = $ret;
return TRUE;
}
}
overload( 'Info' );
$test = new Info( new line );
// [case 1 = fail]
$test->x = FOO;
echo $test->x;
// [case 2 = success]
//$test->x = constant('FOO');
//echo $test->x;
// [case 3 = crash!!!!!]
// When it calls simultaneously
//$test->x = FOO;
//$test->y = constant('FOO');
?>
Expected result:
----------------
//[case 1]
BAR
//[case 2]
BAR
//[case 3]
BAR
BAR
Actual result:
--------------
//[case 1]
xR (why???)
//[case 2]
BAR (ok!!!)
//[case 3]
segfault!!!!!
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 23:00:01 2025 UTC |
Output with case 1 (linux): --------------------------- PHP Warning: String is not zero-terminated (x) (source: /usr/src/web/php/php4/Zend/zend_execute.c:281) in /home/jani/t.php on line 36 Warning: String is not zero-terminated (x) (source: /usr/src/web/php/php4/Zend/zend_execute.c:281) in /home/jani/t.php on line 36 x PHP Warning: String is not zero-terminated (ZZ ?***) (source: /usr/src/web/php/php4/Zend/zend_execute_API.c:291) in Unknown on line 0 Warning: String is not zero-terminated (ZZ ?***) (source: /usr/src/web/php/php4/Zend/zend_execute_API.c:291) in Unknown on line 0 [Sun Jul 11 21:38:02 2004] Script: 't.php' --------------------------------------- /usr/src/web/php/php4/Zend/zend_execute_API.c(291) : Block 0x08618F28 status: /usr/src/web/php/php4/Zend/zend_variables.c(44) : Actual location (location was relayed) Beginning: Cached (allocated on /usr/src/web/php/php4/Zend/zend_execute.c:911, 2 bytes) End: OK --------------------------------------- [Sun Jul 11 21:38:02 2004] Script: 't.php' --------------------------------------- /usr/src/web/php/php4/Zend/zend_execute.h(44) : Block 0xBFFFBCF4 status: Beginning: Overrun (magic=0x00420297, expected=0x7312F8DC) Fatal System Error: Raise at top of Exception Stack Aborted Backtrace: ---------- http://www.php.net/~jani/bug28935_gdb.bt