Fix assertion violation for invalid class const objects in const expressions (#11458)

Fixes oss-fuzz #59764
This commit is contained in:
Ilija Tovilo 2023-06-21 14:59:05 +02:00 committed by GitHub
parent 6c015ae8fe
commit fae42c8bd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1,8 @@
--TEST--
oss-fuzz #59764: Test
--FILE--
<?php
const B = []::{A};
?>
--EXPECTF--
Fatal error: Class name must be a valid object or a string in %s on line %d

View File

@ -10014,6 +10014,9 @@ static void zend_compile_const_expr_class_const(zend_ast **ast_ptr) /* {{{ */
zend_error_noreturn(E_COMPILE_ERROR,
"Dynamic class names are not allowed in compile-time class constant references");
}
if (Z_TYPE_P(zend_ast_get_zval(class_ast)) != IS_STRING) {
zend_throw_error(NULL, "Class name must be a valid object or a string");
}
class_name = zend_ast_get_str(class_ast);
fetch_type = zend_get_class_fetch_type(class_name);