com php-src: Fix anon class handling in ext mode: Zend/zend_c ompile.c

From: Date: Fri, 22 Feb 2019 14:43:08 +0000
Subject: com php-src: Fix anon class handling in ext mode: Zend/zend_c ompile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-104841@lists.php.net to get a copy of this message
Commit: 52605aafc565955436c9f60c33a786302fef7887 Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 22 Feb 2019 15:42:37 +0100 Parents: dda2074bf7bb8a6514b2c29cbf543b8d09ee0603 Branches: PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=52605aafc565955436c9f60c33a786302fef7887 Log: 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. Changed paths: M Zend/zend_compile.c Diff: diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index eee2347..bd7139e 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; } /* }}} */

« previous php.cvs (#104841) next »