File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / tests / bug39297.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:47:52 2012 UTC (13 years, 1 month ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

    1: --TEST--
    2: Bug #39297 (Memory corryption because of indirect modification of overloaded array)
    3: --FILE--
    4: <?php
    5: function compareByRef(&$first, &$second) {
    6:     return $first === $second;
    7: }
    8: 
    9: class MyTree implements ArrayAccess {
   10:     public $parent;
   11:     public $children = array();
   12: 
   13:     public function offsetExists($offset) {
   14:     }
   15: 
   16:     public function offsetUnset($offset) {
   17:     }
   18: 
   19:     public function offsetSet($offset, $value) {
   20:     	echo "offsetSet()\n";
   21:         $cannonicalName = strtolower($offset);
   22:         $this->children[$cannonicalName] = $value;
   23:         $value->parent = $this;
   24:     }    
   25:     
   26:     public function offsetGet($offset) {
   27:     	echo "offsetGet()\n";
   28:         $cannonicalName = strtolower($offset);
   29:         return $this->children[$cannonicalName];
   30:     }
   31: 
   32: }
   33: 
   34: $id = 'Test';
   35: 
   36: $root = new MyTree();
   37: $child = new MyTree();
   38: $root[$id] = $child;
   39: 
   40: var_dump(compareByRef($root[$id], $child));
   41: ?>
   42: --EXPECT--
   43: offsetSet()
   44: offsetGet()
   45: bool(true)

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>