diff options
author | Deus Kane <3399275+qxzkjp@users.noreply.github.com> | 2020-07-25 12:02:01 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-07-30 11:08:31 +0200 |
commit | f475edc2f10964f37e3900dd4c447e7cc0d4fb8c (patch) | |
tree | f1f1393b3daf0e5cad1f1c46fdb3e1a580d02fbc /Zend/zend_compile.c | |
parent | 3690a805c15087f7f04c602e9f3c1e617060c475 (diff) | |
download | php-git-f475edc2f10964f37e3900dd4c447e7cc0d4fb8c.tar.gz |
Fixed bug #79897: Promoted constructor params with attribs cause crash
This was caused by the attribute AST being used twice, and was fixed by
creating a temporary copy of it (and destroying said copy) when neccesary.
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r-- | Zend/zend_compile.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index a2ec221a01..790b2acc89 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6197,6 +6197,12 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32_t fall zend_op *opline; zend_arg_info *arg_info; + zend_ast_ref *attributes_copy = NULL; + + if (visibility && attributes_ast) { + attributes_copy = zend_ast_copy(attributes_ast); + } + if (zend_is_auto_global(name)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot re-assign auto-global variable %s", ZSTR_VAL(name)); @@ -6350,7 +6356,8 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32_t fall scope, name, &default_value, visibility | ZEND_ACC_PROMOTED, doc_comment, type); if (attributes_ast) { zend_compile_attributes( - &prop->attributes, attributes_ast, 0, ZEND_ATTRIBUTE_TARGET_PROPERTY); + &prop->attributes, GC_AST(attributes_copy), 0, ZEND_ATTRIBUTE_TARGET_PROPERTY); + zend_ast_ref_destroy(attributes_copy); } } } |