Skip to content

Commit 53b0a95

Browse files
authored
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 <[email protected]>
1 parent 544617a commit 53b0a95

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Zend/zend_exceptions.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#define ZEND_EXCEPTION_LINE_OFF 4
3737
#define ZEND_EXCEPTION_TRACE_OFF 5
3838
#define ZEND_EXCEPTION_PREVIOUS_OFF 6
39-
#define ZEND_EXCEPTION_SEVERITY_OFF 7
4039

4140
ZEND_API zend_class_entry *zend_ce_throwable;
4241
ZEND_API zend_class_entry *zend_ce_exception;
@@ -415,7 +414,7 @@ ZEND_METHOD(ErrorException, __construct)
415414
}
416415

417416
ZVAL_LONG(&tmp, severity);
418-
zend_update_property_num_checked(NULL, Z_OBJ_P(object), ZEND_EXCEPTION_SEVERITY_OFF, ZSTR_KNOWN(ZEND_STR_SEVERITY), &tmp);
417+
zend_update_property_ex(zend_ce_exception, Z_OBJ_P(object), ZSTR_KNOWN(ZEND_STR_SEVERITY), &tmp);
419418
if (UNEXPECTED(EG(exception))) {
420419
RETURN_THROWS();
421420
}

0 commit comments

Comments
 (0)