Skip to content

Fix unevaluated rhs of class constant fetch in constant expression #11047

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
Apr 10, 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
12 changes: 12 additions & 0 deletions Zend/tests/oss_fuzz_57821.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
oss-fuzz #57821: Unevaluated rhs of class constant fetch in constant expression
--FILE--
<?php
class Foo {
const Foo = 'foo';
}
const C = Foo::{Foo::class};
var_dump(C);
?>
--EXPECT--
string(3) "foo"
6 changes: 3 additions & 3 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -10761,14 +10761,14 @@ static void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
zend_ast *name_ast;
zend_string *resolved_name;

zend_eval_const_expr(&ast->child[0]);
zend_eval_const_expr(&ast->child[1]);

if (UNEXPECTED(ast->child[1]->kind != ZEND_AST_ZVAL
|| Z_TYPE_P(zend_ast_get_zval(ast->child[1])) != IS_STRING)) {
return;
}

zend_eval_const_expr(&ast->child[0]);
zend_eval_const_expr(&ast->child[1]);

class_ast = ast->child[0];
name_ast = ast->child[1];

Expand Down