From: Nikita Popov Date: Fri, 22 Feb 2019 14:42:37 +0000 (+0100) Subject: Fix anon class handling in ext mode X-Git-Tag: php-7.4.0alpha1~902 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=52605aafc565955436c9f60c33a786302fef7887;p=php Fix anon class handling in ext mode Opcode order changes in 7.4 and the EXT_STMT is now declare the DECLARE_ANON. Fix this by returning the opline from compile_class_decl to avoid any fragile opcode searching. --- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index eee2347f49..bd7139eb5d 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3972,7 +3972,7 @@ void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type) /* {{ } /* }}} */ -void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel); +zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel); void zend_compile_new(znode *result, zend_ast *ast) /* {{{ */ { @@ -3983,13 +3983,8 @@ void zend_compile_new(znode *result, zend_ast *ast) /* {{{ */ zend_op *opline; if (class_ast->kind == ZEND_AST_CLASS) { - uint32_t dcl_opnum = get_next_op_number(); - zend_compile_class_decl(class_ast, 0); /* jump over anon class declaration */ - opline = &CG(active_op_array)->opcodes[dcl_opnum]; - if (opline->opcode == ZEND_FETCH_CLASS) { - opline++; - } + opline = zend_compile_class_decl(class_ast, 0); class_node.op_type = opline->result_type; class_node.u.op.var = opline->result.var; opline->extended_value = get_next_op_number(); @@ -6181,7 +6176,7 @@ static zend_string *zend_generate_anon_class_name(unsigned char *lex_pos) /* {{{ } /* }}} */ -void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */ +zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */ { zend_ast_decl *decl = (zend_ast_decl *) ast; zend_ast *extends_ast = decl->child[0]; @@ -6341,7 +6336,7 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */ } CG(zend_lineno) = ast->lineno; zend_string_release(lcname); - return; + return NULL; } } } else { @@ -6349,7 +6344,7 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */ zend_string_release(lcname); zend_build_properties_info_table(ce); ce->ce_flags |= ZEND_ACC_LINKED; - return; + return NULL; } } } @@ -6375,7 +6370,7 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */ zval zv; ZVAL_PTR(&zv, ce); destroy_zend_class(&zv); - return; + return opline; } } else { zend_string *key = zend_build_runtime_definition_key(lcname, decl->lex_pos); @@ -6402,6 +6397,7 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */ opline->opcode = ZEND_DECLARE_CLASS; } } + return opline; } /* }}} */