@@ -732,6 +732,11 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en
732
732
closure -> func .common .fn_flags |= ZEND_ACC_CLOSURE ;
733
733
closure -> func .common .fn_flags &= ~ZEND_ACC_IMMUTABLE ;
734
734
735
+ zend_string_addref (closure -> func .op_array .function_name );
736
+ if (closure -> func .op_array .refcount ) {
737
+ (* closure -> func .op_array .refcount )++ ;
738
+ }
739
+
735
740
/* For fake closures, we want to reuse the static variables of the original function. */
736
741
if (!is_fake ) {
737
742
if (closure -> func .op_array .static_variables ) {
@@ -765,22 +770,17 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en
765
770
if (func -> common .scope != scope ) {
766
771
func -> common .scope = scope ;
767
772
}
768
- closure -> func .op_array .fn_flags &= ~ZEND_ACC_HEAP_RT_CACHE ;
769
773
ptr = zend_arena_alloc (& CG (arena ), func -> op_array .cache_size );
770
774
ZEND_MAP_PTR_SET (func -> op_array .run_time_cache , ptr );
775
+ closure -> func .op_array .fn_flags &= ~ZEND_ACC_HEAP_RT_CACHE ;
771
776
} else {
772
777
/* Otherwise, we use a non-shared runtime cache */
773
- closure -> func .op_array .fn_flags |= ZEND_ACC_HEAP_RT_CACHE ;
774
778
ptr = emalloc (func -> op_array .cache_size );
779
+ closure -> func .op_array .fn_flags |= ZEND_ACC_HEAP_RT_CACHE ;
775
780
}
776
781
memset (ptr , 0 , func -> op_array .cache_size );
777
782
}
778
783
ZEND_MAP_PTR_INIT (closure -> func .op_array .run_time_cache , ptr );
779
-
780
- zend_string_addref (closure -> func .op_array .function_name );
781
- if (closure -> func .op_array .refcount ) {
782
- (* closure -> func .op_array .refcount )++ ;
783
- }
784
784
} else {
785
785
memcpy (& closure -> func , func , sizeof (zend_internal_function ));
786
786
closure -> func .common .fn_flags |= ZEND_ACC_CLOSURE ;
0 commit comments