Skip to content

Commit eeccadd

Browse files
committed
Do not run destructors when an exception has been raised
Found an existing bug with private constructors
1 parent 8f2e65b commit eeccadd

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

Zend/zend_API.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,7 @@ ZEND_API zend_result object_init_with_constructor(zval *arg, zend_class_entry *c
18731873
named_params
18741874
);
18751875
if (Z_TYPE(retval) == IS_UNDEF) {
1876+
zend_object_store_ctor_failed(obj);
18761877
zval_ptr_dtor(arg);
18771878
ZVAL_UNDEF(arg);
18781879
return FAILURE;

ext/zend_test/tests/zend_object_init_with_constructor.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,9 @@ Error: Cannot instantiate abstract class AbstractClass
116116
Error: Cannot directly construct SysvMessageQueue, use msg_get_queue() instead
117117
Destructor for PrivateUser
118118
Error: Call to private PrivateUser::__construct() from global scope
119-
Destructor for ThrowingUser
120119
Exception: Don't construct
121120
Testing param passing
122-
Destructor for TestUser
123121
ArgumentCountError: Too few arguments to function TestUser::__construct(), 0 passed and exactly 2 expected
124-
Destructor for TestUser
125122
TypeError: TestUser::__construct(): Argument #1 ($int_param) must be of type int, string given
126123
object(TestUser)#3 (0) {
127124
}

0 commit comments

Comments
 (0)