From: Dmitry Stogov Date: Thu, 26 Mar 2009 10:17:47 +0000 (+0000) Subject: Fixed bug #47771 (Exception during object construction from arg call calls object... X-Git-Tag: php-5.4.0alpha1~191^2~4053 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=91ca700dd9f1f5b099beeb0ddff3564b86da8f1c;p=php Fixed bug #47771 (Exception during object construction from arg call calls object's destructor) --- diff --git a/Zend/tests/bug47771.phpt b/Zend/tests/bug47771.phpt new file mode 100644 index 0000000000..a17fcf3b58 --- /dev/null +++ b/Zend/tests/bug47771.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #47771 (Exception during object construction from arg call calls object's destructor) +--FILE-- +getMessage() . "\n"; +} +?> +--EXPECT-- +Exception: TEST_EXCEPTION diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index ee2681ddaa..7d674326ba 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -4472,8 +4472,13 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) 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)); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 56194b68e1..c39d5449dc 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -633,8 +633,13 @@ static int ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(ZEND_OPCODE_HANDLER 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)); }