Skip to content

Commit e8b9443

Browse files
committed
Handle exceptions during create_object handler more gracefully
This is a bit ugly...
1 parent 21df2e4 commit e8b9443

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Zend/zend_API.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,9 +1644,12 @@ static zend_always_inline zend_result _object_and_properties_init(zval *arg, zen
16441644
return SUCCESS;
16451645
}
16461646
} else {
1647-
ZEND_ASSERT(!EG(exception));
1647+
/* Report failure if an exception is thrown during create_object(). However, don't
1648+
* report a failure if an exception already exists, as this causes problems with
1649+
* extension code that does not handle exceptions early enough. */
1650+
bool had_exception = EG(exception) != NULL;
16481651
ZVAL_OBJ(arg, class_type->create_object(class_type));
1649-
if (EXPECTED(!EG(exception))) {
1652+
if (EXPECTED(!EG(exception) || had_exception)) {
16501653
return SUCCESS;
16511654
}
16521655
}

0 commit comments

Comments
 (0)