@@ -160,15 +160,21 @@ ZEND_METHOD(Closure, call)
160
160
/* copied upon generator creation */
161
161
GC_DELREF (& closure -> std );
162
162
} else {
163
+ zend_closure * fake_closure ;
163
164
zend_function * my_function ;
165
+
166
+ fake_closure = emalloc (sizeof (zend_closure ));
167
+ memset (& fake_closure -> std , 0 , sizeof (fake_closure -> std ));
168
+ fake_closure -> std .gc .refcount = 1 ;
169
+ fake_closure -> std .gc .u .type_info = GC_NULL ;
170
+ ZVAL_UNDEF (& fake_closure -> this_ptr );
171
+ fake_closure -> called_scope = NULL ;
172
+ my_function = & fake_closure -> func ;
164
173
if (ZEND_USER_CODE (closure -> func .type )) {
165
- my_function = emalloc (sizeof (zend_op_array ));
166
174
memcpy (my_function , & closure -> func , sizeof (zend_op_array ));
167
175
} else {
168
- my_function = emalloc (sizeof (zend_internal_function ));
169
176
memcpy (my_function , & closure -> func , sizeof (zend_internal_function ));
170
177
}
171
- my_function -> common .fn_flags &= ~ZEND_ACC_CLOSURE ;
172
178
/* use scope of passed object */
173
179
my_function -> common .scope = newclass ;
174
180
if (closure -> func .type == ZEND_INTERNAL_FUNCTION ) {
@@ -194,10 +200,8 @@ ZEND_METHOD(Closure, call)
194
200
if (fci_cache .function_handler -> common .fn_flags & ZEND_ACC_HEAP_RT_CACHE ) {
195
201
efree (ZEND_MAP_PTR (my_function -> op_array .run_time_cache ));
196
202
}
197
- efree_size (my_function , sizeof (zend_op_array ));
198
- } else {
199
- efree_size (my_function , sizeof (zend_internal_function ));
200
203
}
204
+ efree_size (fake_closure , sizeof (zend_closure ));
201
205
}
202
206
203
207
if (Z_TYPE (closure_result ) != IS_UNDEF ) {
0 commit comments