cvs: ZendEngine2 / zend_execute.c /tests bug31828.phpt bug32080.phpt bug32852.phpt
| From: | Dmitry Stogov | Date: | Fri, 29 Apr 2005 07:03:54 +0000 |
| Subject: | cvs: ZendEngine2 / zend_execute.c /tests bug31828.phpt bug32080.phpt bug32852.phpt | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-3614@lists.php.net to get a copy of this message | ||
dmitry Fri Apr 29 03:03:54 2005 EDT
Modified files:
/ZendEngine2 zend_execute.c
/ZendEngine2/tests bug31828.phpt bug32080.phpt bug32852.phpt
Log:
Fixed bug #32852 (Crash with singleton and __destruct when zend.ze1_compatibility_mode = On)
Fixed bug #31828 (Crash with zend.ze1_compatibility_mode=On)
Fixed bug #32080 (segfault when assigning object to itself with zend.ze1_compatibility_mode=On)
http://cvs.php.net/diff.php/ZendEngine2/zend_execute.c?r1=1.694&r2=1.695&ty=u
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.694 ZendEngine2/zend_execute.c:1.695
--- ZendEngine2/zend_execute.c:1.694 Fri Apr 15 13:15:15 2005
+++ ZendEngine2/zend_execute.c Fri Apr 29 03:03:53 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.694 2005/04/15 17:15:15 andrei Exp $ */
+/* $Id: zend_execute.c,v 1.695 2005/04/29 07:03:53 dmitry Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -800,7 +800,7 @@
if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) {
zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s",
Z_OBJCE_P(value)->name);
} else if (PZVAL_IS_REF(variable_ptr)) {
- if (variable_ptr != value) {
+ if (variable_ptr != value) {
zend_uint refcount = variable_ptr->refcount;
zval garbage;
@@ -819,17 +819,21 @@
zendi_zval_dtor(garbage);
}
} else {
- variable_ptr->refcount--;
- if (variable_ptr->refcount == 0) {
- zendi_zval_dtor(*variable_ptr);
- } else {
- ALLOC_ZVAL(variable_ptr);
- *variable_ptr_ptr = variable_ptr;
+ if (variable_ptr != value) {
+ value->refcount++;
+ variable_ptr->refcount--;
+ if (variable_ptr->refcount == 0) {
+ zendi_zval_dtor(*variable_ptr);
+ } else {
+ ALLOC_ZVAL(variable_ptr);
+ *variable_ptr_ptr = variable_ptr;
+ }
+ *variable_ptr = *value;
+ INIT_PZVAL(variable_ptr);
+ zend_error(E_STRICT, "Implicit cloning object of class '%s' because of
'zend.ze1_compatibility_mode'", Z_OBJCE_P(value)->name);
+ variable_ptr->value.obj = Z_OBJ_HANDLER_P(value, clone_obj)(value TSRMLS_CC);
+ zval_ptr_dtor(&value);
}
- *variable_ptr = *value;
- INIT_PZVAL(variable_ptr);
- zend_error(E_STRICT, "Implicit cloning object of class '%s' because of
'zend.ze1_compatibility_mode'", Z_OBJCE_P(value)->name);
- variable_ptr->value.obj = Z_OBJ_HANDLER_P(value, clone_obj)(value TSRMLS_CC);
}
} else if (PZVAL_IS_REF(variable_ptr)) {
if (variable_ptr!=value) {
http://cvs.php.net/diff.php/ZendEngine2/tests/bug31828.phpt?r1=1.1&r2=1.2&ty=u
Index: ZendEngine2/tests/bug31828.phpt
diff -u /dev/null ZendEngine2/tests/bug31828.phpt:1.2
--- /dev/null Fri Apr 29 03:03:54 2005
+++ ZendEngine2/tests/bug31828.phpt Fri Apr 29 03:03:54 2005
@@ -0,0 +1,19 @@
+--TSTE--
+Bug #31828 (Crash with zend.ze1_compatibility_mode=On)
+--INI--
+zend.ze1_compatibility_mode=on
+--FILE--
+<?php
+$o = new stdClass();
+$o->id = 77;
+$o->name = "Aerospace";
+$a[] = $o;
+$a = $a[0];
+print_r($a);
+?>
+--EXPECT--
+stdClass Object
+(
+ [id] => 77
+ [name] => Aerospace
+)
http://cvs.php.net/diff.php/ZendEngine2/tests/bug32080.phpt?r1=1.1&r2=1.2&ty=u
Index: ZendEngine2/tests/bug32080.phpt
diff -u /dev/null ZendEngine2/tests/bug32080.phpt:1.2
--- /dev/null Fri Apr 29 03:03:54 2005
+++ ZendEngine2/tests/bug32080.phpt Fri Apr 29 03:03:54 2005
@@ -0,0 +1,14 @@
+--TSTE--
+Bug #32080 (segfault when assigning object to itself with zend.ze1_compatibility_mode=On)
+--INI--
+zend.ze1_compatibility_mode=on
+--FILE--
+<?php
+class test { }
+$t = new test;
+$t = $t; // gives segfault
+var_dump($t);
+?>
+--EXPECT--
+object(test)#2 (0) {
+}
http://cvs.php.net/diff.php/ZendEngine2/tests/bug32852.phpt?r1=1.1&r2=1.2&ty=u
Index: ZendEngine2/tests/bug32852.phpt
diff -u /dev/null ZendEngine2/tests/bug32852.phpt:1.2
--- /dev/null Fri Apr 29 03:03:54 2005
+++ ZendEngine2/tests/bug32852.phpt Fri Apr 29 03:03:54 2005
@@ -0,0 +1,37 @@
+--TEST--
+Bug #32852 (Crash with singleton and __destruct when zend.ze1_compatibility_mode = On)
+--INI--
+zend.ze1_compatibility_mode=on
+--FILE--
+<?php
+class crashme {
+ private static $instance = null;
+
+ public function __construct() {
+ self::$instance = $this;
+ }
+
+ public function __destruct() {
+ echo "i'm called\n";
+ }
+
+ public static function singleton() {
+ if (!isset(self::$instance)) {
+ self::$instance = new crashme();
+ }
+ return self::$instance;
+ }
+}
+
+crashme::singleton();
+?>
+--EXPECTF--
+Strict Standards: Implicit cloning object of class 'crashme' because of
'zend.ze1_compatibility_mode' in %sbug32852.php on line 6
+i'm called
+
+Strict Standards: Implicit cloning object of class 'crashme' because of
'zend.ze1_compatibility_mode' in %sbug32852.php on line 15
+i'm called
+
+Strict Standards: Implicit cloning object of class 'crashme' because of
'zend.ze1_compatibility_mode' in %sbug32852.php on line 17
+i'm called
+i'm called