Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Zend/tests/oss_fuzz_59764.phpt
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down