1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Avoid hardcoding the offset for ErrorException specific properties (#20096)

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 <bobwei9@hotmail.com>
This commit is contained in:
Bob Weinand
2025-10-07 22:12:52 +02:00
committed by GitHub
parent 544617a3fa
commit 53b0a95545

View File

@@ -36,7 +36,6 @@
#define ZEND_EXCEPTION_LINE_OFF 4 #define ZEND_EXCEPTION_LINE_OFF 4
#define ZEND_EXCEPTION_TRACE_OFF 5 #define ZEND_EXCEPTION_TRACE_OFF 5
#define ZEND_EXCEPTION_PREVIOUS_OFF 6 #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_throwable;
ZEND_API zend_class_entry *zend_ce_exception; ZEND_API zend_class_entry *zend_ce_exception;
@@ -415,7 +414,7 @@ ZEND_METHOD(ErrorException, __construct)
} }
ZVAL_LONG(&tmp, severity); 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))) { if (UNEXPECTED(EG(exception))) {
RETURN_THROWS(); RETURN_THROWS();
} }