Annotation of embedaddon/php/Zend/tests/bug39297.phpt, revision 1.1
1.1 ! misho 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>