cvs: ZendEngine2 / zend_vm_def.h zend_vm_execute.h /tests bug47771.phpt
[email protected] ("Dmitry Stogov") Thu, 26 Mar 2009 10:17:47 -0000
| Newsgroups | php.zend-engine.cvs |
|---|---|
| Message-ID | <cvsdmitry1238062667@cvsserver> |
dmitry Thu Mar 26 10:17:47 2009 UTC
Modified files:
/ZendEngine2 zend_vm_def.h zend_vm_execute.h
/ZendEngine2/tests bug47771.phpt
Log:
Fixed bug #47771 (Exception during object construction from arg call calls object's destructor)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_def.h?r1=1.260&r2=1.261&diff_format=u
Index: ZendEngine2/zend_vm_def.h
diff -u ZendEngine2/zend_vm_def.h:1.260 ZendEngine2/zend_vm_def.h:1.261
--- ZendEngine2/zend_vm_def.h:1.260 Wed Mar 18 18:48:52 2009
+++ ZendEngine2/zend_vm_def.h Thu Mar 26 10:17:47 2009
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_vm_def.h,v 1.260 2009/03/18 18:48:52 dmitry Exp $ */
+/* $Id: zend_vm_def.h,v 1.261 2009/03/26 10:17:47 dmitry Exp $ */
/* If you change this file, please regenerate the zend_vm_execute.h and
* zend_vm_opcodes.h files by running:
@@ -4472,8 +4472,13 @@
while (EX(fbc)) {
EX(called_scope) = (zend_class_entry*)zend_ptr_stack_pop(&EG(arg_types_stack));
if (EX(object)) {
- if (IS_CTOR_USED(EX(called_scope))) {
- Z_DELREF_P(EX(object));
+ if (IS_CTOR_CALL(EX(called_scope))) {
+ if (IS_CTOR_USED(EX(called_scope))) {
+ Z_DELREF_P(EX(object));
+ }
+ if (Z_REFCOUNT_P(EX(object)) == 1) {
+ zend_object_store_ctor_failed(EX(object) TSRMLS_CC);
+ }
}
zval_ptr_dtor(&EX(object));
}
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.h?r1=1.264&r2=1.265&diff_format=u
Index: ZendEngine2/zend_vm_execute.h
diff -u ZendEngine2/zend_vm_execute.h:1.264 ZendEngine2/zend_vm_execute.h:1.265
--- ZendEngine2/zend_vm_execute.h:1.264 Wed Mar 18 18:48:52 2009
+++ ZendEngine2/zend_vm_execute.h Thu Mar 26 10:17:47 2009
@@ -633,8 +633,13 @@
while (EX(fbc)) {
EX(called_scope) = (zend_class_entry*)zend_ptr_stack_pop(&EG(arg_types_stack));
if (EX(object)) {
- if (IS_CTOR_USED(EX(called_scope))) {
- Z_DELREF_P(EX(object));
+ if (IS_CTOR_CALL(EX(called_scope))) {
+ if (IS_CTOR_USED(EX(called_scope))) {
+ Z_DELREF_P(EX(object));
+ }
+ if (Z_REFCOUNT_P(EX(object)) == 1) {
+ zend_object_store_ctor_failed(EX(object) TSRMLS_CC);
+ }
}
zval_ptr_dtor(&EX(object));
}
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug47771.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/bug47771.phpt
diff -u /dev/null ZendEngine2/tests/bug47771.phpt:1.2
--- /dev/null Thu Mar 26 10:17:47 2009
+++ ZendEngine2/tests/bug47771.phpt Thu Mar 26 10:17:47 2009
@@ -0,0 +1,30 @@
+--TEST--
+Bug #47771 (Exception during object construction from arg call calls object's destructor)
+--FILE--
+<?php
+function throw_exc() {
+ throw new Exception('TEST_EXCEPTION');
+}
+
+class Test {
+
+ public function __construct() {
+ echo 'Constr' ."\n";
+ }
+
+ public function __destruct() {
+ echo 'Destr' ."\n";
+ }
+
+}
+
+try {
+
+ $T =new Test(throw_exc());
+
+} catch( Exception $e) {
+ echo 'Exception: ' . $e->getMessage() . "\n";
+}
+?>
+--EXPECT--
+Exception: TEST_EXCEPTION