Skip to content

Commit fae42c8

Browse files
authored
Fix assertion violation for invalid class const objects in const expressions (#11458)
Fixes oss-fuzz #59764
1 parent 6c015ae commit fae42c8

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Zend/tests/oss_fuzz_59764.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
oss-fuzz #59764: Test
3+
--FILE--
4+
<?php
5+
const B = []::{A};
6+
?>
7+
--EXPECTF--
8+
Fatal error: Class name must be a valid object or a string in %s on line %d

Zend/zend_compile.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10014,6 +10014,9 @@ static void zend_compile_const_expr_class_const(zend_ast **ast_ptr) /* {{{ */
1001410014
zend_error_noreturn(E_COMPILE_ERROR,
1001510015
"Dynamic class names are not allowed in compile-time class constant references");
1001610016
}
10017+
if (Z_TYPE_P(zend_ast_get_zval(class_ast)) != IS_STRING) {
10018+
zend_throw_error(NULL, "Class name must be a valid object or a string");
10019+
}
1001710020

1001810021
class_name = zend_ast_get_str(class_ast);
1001910022
fetch_type = zend_get_class_fetch_type(class_name);

0 commit comments

Comments
 (0)