From 04a7d0e8621545c74bc2d91963b726c37d4cbb66 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Tue, 7 Oct 2025 18:53:08 +0200 Subject: [PATCH] Avoid hardcoding the offset for ErrorException specific properties. While I consider it fine to hardcode offsets for parent-less classes, doing it on inherited classes prohibits adding additional properties via extensions. In this specific case, an added property to Exception will cause "new ErrorException" to crash. Signed-off-by: Bob Weinand --- Zend/zend_exceptions.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 0b0945aac0f44..77b754c91086c 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -36,7 +36,6 @@ #define ZEND_EXCEPTION_LINE_OFF 4 #define ZEND_EXCEPTION_TRACE_OFF 5 #define ZEND_EXCEPTION_PREVIOUS_OFF 6 -#define ZEND_EXCEPTION_SEVERITY_OFF 7 ZEND_API zend_class_entry *zend_ce_throwable; ZEND_API zend_class_entry *zend_ce_exception; @@ -415,7 +414,7 @@ ZEND_METHOD(ErrorException, __construct) } ZVAL_LONG(&tmp, severity); - zend_update_property_num_checked(NULL, Z_OBJ_P(object), ZEND_EXCEPTION_SEVERITY_OFF, ZSTR_KNOWN(ZEND_STR_SEVERITY), &tmp); + zend_update_property_ex(zend_ce_exception, Z_OBJ_P(object), ZSTR_KNOWN(ZEND_STR_SEVERITY), &tmp); if (UNEXPECTED(EG(exception))) { RETURN_THROWS(); }