Skip to content

Commit 6cc4e32

Browse files
committed
Only assign $severity for ErrorException
This code is used by generic EH_THROW with arbitrary Exception types, while only ErrorException has a $severity property. We don't want this code to add $severity properties to random exception types like PDOException.
1 parent 29c6eb6 commit 6cc4e32

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Zend/zend_exceptions.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -850,10 +850,12 @@ ZEND_API ZEND_COLD zend_object *zend_throw_exception_ex(zend_class_entry *except
850850

851851
ZEND_API ZEND_COLD zend_object *zend_throw_error_exception(zend_class_entry *exception_ce, zend_string *message, zend_long code, int severity) /* {{{ */
852852
{
853-
zval tmp;
854853
zend_object *obj = zend_throw_exception_zstr(exception_ce, message, code);
855-
ZVAL_LONG(&tmp, severity);
856-
zend_update_property_ex(zend_ce_error_exception, obj, ZSTR_KNOWN(ZEND_STR_SEVERITY), &tmp);
854+
if (exception_ce && instanceof_function(exception_ce, zend_ce_error_exception)) {
855+
zval tmp;
856+
ZVAL_LONG(&tmp, severity);
857+
zend_update_property_ex(zend_ce_error_exception, obj, ZSTR_KNOWN(ZEND_STR_SEVERITY), &tmp);
858+
}
857859
return obj;
858860
}
859861
/* }}} */

0 commit comments

Comments
 (0)