dmitry Mon Mar 19 18:36:50 2007 UTC
Modified files:
/ZendEngine2/tests bug40833.phpt
/ZendEngine2 zend_vm_def.h zend_vm_execute.h
Log:
Fixed bug #40833 (Crash when using unset() on an ArrayAccess object retrieved
via __get()).
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug40833.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/bug40833.phpt
diff -u /dev/null ZendEngine2/tests/bug40833.phpt:1.2
--- /dev/null Mon Mar 19 18:36:50 2007
+++ ZendEngine2/tests/bug40833.phpt Mon Mar 19 18:36:49 2007
@@ -0,0 +1,72 @@
+--TEST--
+Bug #40833 (Crash when using unset() on an ArrayAccess object retrieved via
__get)
+--FILE--
+<?php
+ class entity
+ {
+ private $data;
+ private $modified;
+
+ function __get($name)
+ {
+ if ( isset($this->data[$name]) )
+ return $this->data[$name];
+ else
+ return $this->data[$name] = new set($this);
+ }
+
+ function __set($name, $value)
+ {
+ $this->modified[$name] = $value;
+ }
+ }
+
+ class set implements ArrayAccess
+ {
+ private $entity;
+
+ function __construct($entity)
+ {
+ $this->entity = $entity;
+ $this->entity->whatever = $this;
+ }
+
+ function clear() {
+ $this->entity->whatever = null;
+ }
+
+ function offsetUnset($offset)
+ {
+ $this->clear();
+// $this->entity->{$this->name} = null;
+ }
+
+ function offsetSet($offset, $value)
+ {
+ }
+
+ function offsetGet($offset)
+ {
+ return 'Bogus ';
+ }
+
+ function offsetExists($offset)
+ {
+ }
+ }
+
+ $entity = new entity();
+ echo($entity->whatever[0]);
+
+ //This will crash
+// $entity->whatever->clear();
+ unset($entity->whatever[0]);
+
+ //This will not crash (comment previous & uncomment this to test
+// $test = $entity->whatever; unset($test[0]);
+
+ echo($entity->whatever[0]);
+ echo "ok\n";
+?>
+--EXPECT--
+Bogus Bogus ok
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_def.h?r1=1.162&r2=1.163&diff_format=u
Index: ZendEngine2/zend_vm_def.h
diff -u ZendEngine2/zend_vm_def.h:1.162 ZendEngine2/zend_vm_def.h:1.163
--- ZendEngine2/zend_vm_def.h:1.162 Thu Mar 8 21:06:54 2007
+++ ZendEngine2/zend_vm_def.h Mon Mar 19 18:36:49 2007
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_vm_def.h,v 1.162 2007/03/08 21:06:54 stas Exp $ */
+/* $Id: zend_vm_def.h,v 1.163 2007/03/19 18:36:49 dmitry Exp $ */
/* If you change this file, please regenerate the zend_vm_execute.h and
* zend_vm_opcodes.h files by running:
@@ -1361,7 +1361,7 @@
if (IS_OP2_TMP_FREE()) {
MAKE_REAL_ZVAL_PTR(property);
}
-
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_R TSRMLS_CC);
+
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_UNSET TSRMLS_CC);
if (IS_OP2_TMP_FREE()) {
zval_ptr_dtor(&property);
} else {
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.h?r1=1.165&r2=1.166&diff_format=u
Index: ZendEngine2/zend_vm_execute.h
diff -u ZendEngine2/zend_vm_execute.h:1.165 ZendEngine2/zend_vm_execute.h:1.166
--- ZendEngine2/zend_vm_execute.h:1.165 Thu Mar 8 21:06:53 2007
+++ ZendEngine2/zend_vm_execute.h Mon Mar 19 18:36:49 2007
@@ -9488,7 +9488,7 @@
if (0) {
MAKE_REAL_ZVAL_PTR(property);
}
-
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_R TSRMLS_CC);
+
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_UNSET TSRMLS_CC);
if (0) {
zval_ptr_dtor(&property);
} else {
@@ -11027,7 +11027,7 @@
if (1) {
MAKE_REAL_ZVAL_PTR(property);
}
-
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_R TSRMLS_CC);
+
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_UNSET TSRMLS_CC);
if (1) {
zval_ptr_dtor(&property);
} else {
@@ -12569,7 +12569,7 @@
if (0) {
MAKE_REAL_ZVAL_PTR(property);
}
-
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_R TSRMLS_CC);
+
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_UNSET TSRMLS_CC);
if (0) {
zval_ptr_dtor(&property);
} else {
@@ -14584,7 +14584,7 @@
if (0) {
MAKE_REAL_ZVAL_PTR(property);
}
-
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_R TSRMLS_CC);
+
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_UNSET TSRMLS_CC);
if (0) {
zval_ptr_dtor(&property);
} else {
@@ -15878,7 +15878,7 @@
if (0) {
MAKE_REAL_ZVAL_PTR(property);
}
-
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_R TSRMLS_CC);
+
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_UNSET TSRMLS_CC);
if (0) {
zval_ptr_dtor(&property);
} else {
@@ -16937,7 +16937,7 @@
if (1) {
MAKE_REAL_ZVAL_PTR(property);
}
-
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_R TSRMLS_CC);
+
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_UNSET TSRMLS_CC);
if (1) {
zval_ptr_dtor(&property);
} else {
@@ -17954,7 +17954,7 @@
if (0) {
MAKE_REAL_ZVAL_PTR(property);
}
-
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_R TSRMLS_CC);
+
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_UNSET TSRMLS_CC);
if (0) {
zval_ptr_dtor(&property);
} else {
@@ -19236,7 +19236,7 @@
if (0) {
MAKE_REAL_ZVAL_PTR(property);
}
-
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_R TSRMLS_CC);
+
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_UNSET TSRMLS_CC);
if (0) {
zval_ptr_dtor(&property);
} else {
@@ -21933,7 +21933,7 @@
if (0) {
MAKE_REAL_ZVAL_PTR(property);
}
-
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_R TSRMLS_CC);
+
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_UNSET TSRMLS_CC);
if (0) {
zval_ptr_dtor(&property);
} else {
@@ -23464,7 +23464,7 @@
if (1) {
MAKE_REAL_ZVAL_PTR(property);
}
-
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_R TSRMLS_CC);
+
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_UNSET TSRMLS_CC);
if (1) {
zval_ptr_dtor(&property);
} else {
@@ -24998,7 +24998,7 @@
if (0) {
MAKE_REAL_ZVAL_PTR(property);
}
-
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_R TSRMLS_CC);
+
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_UNSET TSRMLS_CC);
if (0) {
zval_ptr_dtor(&property);
} else {
@@ -27003,7 +27003,7 @@
if (0) {
MAKE_REAL_ZVAL_PTR(property);
}
-
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_R TSRMLS_CC);
+
zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var),
container, property, BP_VAR_UNSET TSRMLS_CC);
if (0) {
zval_ptr_dtor(&property);
} else {
--
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|