From:             kevin at kevin-online dot com
Operating system: Gentoo Linux (2.4.20-gentoo-r2)
PHP version:      4.3.2
PHP Bug Type:     *Programming Data Structures
Bug description:  Broken references while using array_pop in a tree / linked list

Description:
------------
While building up a tree structure, i got strange troubles with some
broken references. 
I used an array as stack holding references to objects. Some references
within the object were broken after using a reference returned by
array_pop.
PHP 4.3.2-r4
(Apache/1.3.28)

Reproduce code:
---------------
class Gnaa {
        var $something;
        var $name;
        function Gnaa( $name ) { $this->name = $name;}
        
        function setGnaa( &$something ) { $this->something = &$something; }
        function &getGnaa() { return $something; }
}

$a =& new Gnaa("a");
$stack[] = &$a;

$b =& new Gnaa("b");
$stack[] = &$b;

$child = &array_pop($stack); // should be &$b
$child->setGnaa( &$a );

print_r($child); // output differs!
print_r( $b );   // 


Expected result:
----------------
That $b has the reference to $a, because $child should be a reference to
$b.


-- 
Edit bug report at http://bugs.php.net/?id=25222&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25222&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25222&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=25222&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=25222&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=25222&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=25222&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=25222&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=25222&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=25222&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=25222&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=25222&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25222&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=25222&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=25222&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=25222&r=gnused

Reply via email to