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)
190
190
node = (zend_ast * ) copy ;
191
191
} else if (ast -> kind == ZEND_AST_OP_ARRAY ) {
192
192
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 );
193
196
zval z ;
194
197
ZVAL_PTR (& z , copy -> op_array );
195
198
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)
91
91
zval z ;
92
92
ZVAL_PTR (& z , zend_ast_get_op_array (ast )-> op_array );
93
93
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
+ }
94
102
} else if (zend_ast_is_decl (ast )) {
95
103
/* Not implemented. */
96
104
ZEND_UNREACHABLE ();
You can’t perform that action at this time.
0 commit comments