--- /dev/null
+--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
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));
}
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));
}