File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,9 @@ static zend_ast *zend_persist_ast(zend_ast *ast)
190190 node = (zend_ast * ) copy ;
191191 } else if (ast -> kind == ZEND_AST_OP_ARRAY ) {
192192 zend_ast_op_array * copy = zend_shared_memdup (ast , sizeof (zend_ast_op_array ));
193+ /* We're holding a separate reference to the op_array in the AST. Release it
194+ * early because zend_persist_op_array() is destructive. */
195+ destroy_op_array (copy -> op_array );
193196 zval z ;
194197 ZVAL_PTR (& z , copy -> op_array );
195198 zend_persist_op_array (& z );
Original file line number Diff line number Diff line change @@ -91,6 +91,14 @@ static void zend_persist_ast_calc(zend_ast *ast)
9191 zval z ;
9292 ZVAL_PTR (& z , zend_ast_get_op_array (ast )-> op_array );
9393 zend_persist_op_array_calc (& z );
94+
95+ /* If op_array is shared, the function name refcount is still incremented for each use,
96+ * so we need to release it here. We remembered the original function name in xlat. */
97+ zend_string * old_function_name =
98+ zend_shared_alloc_get_xlat_entry (& zend_ast_get_op_array (ast )-> op_array -> function_name );
99+ if (old_function_name ) {
100+ zend_string_release_ex (old_function_name , 0 );
101+ }
94102 } else if (ast -> kind == ZEND_AST_CALLABLE_CONVERT ) {
95103 ADD_SIZE (sizeof (zend_ast_fcc ));
96104 } else if (zend_ast_is_decl (ast )) {
You can’t perform that action at this time.
0 commit comments