Skip to content

Commit 52605aa

Browse files
committed
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.
1 parent dda2074 commit 52605aa

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

Zend/zend_compile.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3972,7 +3972,7 @@ void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type) /* {{
39723972
}
39733973
/* }}} */
39743974

3975-
void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel);
3975+
zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel);
39763976

39773977
void zend_compile_new(znode *result, zend_ast *ast) /* {{{ */
39783978
{
@@ -3983,13 +3983,8 @@ void zend_compile_new(znode *result, zend_ast *ast) /* {{{ */
39833983
zend_op *opline;
39843984

39853985
if (class_ast->kind == ZEND_AST_CLASS) {
3986-
uint32_t dcl_opnum = get_next_op_number();
3987-
zend_compile_class_decl(class_ast, 0);
39883986
/* jump over anon class declaration */
3989-
opline = &CG(active_op_array)->opcodes[dcl_opnum];
3990-
if (opline->opcode == ZEND_FETCH_CLASS) {
3991-
opline++;
3992-
}
3987+
opline = zend_compile_class_decl(class_ast, 0);
39933988
class_node.op_type = opline->result_type;
39943989
class_node.u.op.var = opline->result.var;
39953990
opline->extended_value = get_next_op_number();
@@ -6181,7 +6176,7 @@ static zend_string *zend_generate_anon_class_name(unsigned char *lex_pos) /* {{{
61816176
}
61826177
/* }}} */
61836178

6184-
void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
6179+
zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
61856180
{
61866181
zend_ast_decl *decl = (zend_ast_decl *) ast;
61876182
zend_ast *extends_ast = decl->child[0];
@@ -6341,15 +6336,15 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
63416336
}
63426337
CG(zend_lineno) = ast->lineno;
63436338
zend_string_release(lcname);
6344-
return;
6339+
return NULL;
63456340
}
63466341
}
63476342
} else {
63486343
if (EXPECTED(zend_hash_add_ptr(CG(class_table), lcname, ce) != NULL)) {
63496344
zend_string_release(lcname);
63506345
zend_build_properties_info_table(ce);
63516346
ce->ce_flags |= ZEND_ACC_LINKED;
6352-
return;
6347+
return NULL;
63536348
}
63546349
}
63556350
}
@@ -6375,7 +6370,7 @@ void zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */
63756370
zval zv;
63766371
ZVAL_PTR(&zv, ce);
63776372
destroy_zend_class(&zv);
6378-
return;
6373+
return opline;
63796374
}
63806375
} else {
63816376
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) /* {{{ */
64026397
opline->opcode = ZEND_DECLARE_CLASS;
64036398
}
64046399
}
6400+
return opline;
64056401
}
64066402
/* }}} */
64076403

0 commit comments

Comments
 (0)