@@ -725,6 +725,11 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en
725
725
closure -> func .common .fn_flags |= ZEND_ACC_CLOSURE ;
726
726
closure -> func .common .fn_flags &= ~ZEND_ACC_IMMUTABLE ;
727
727
728
+ zend_string_addref (closure -> func .op_array .function_name );
729
+ if (closure -> func .op_array .refcount ) {
730
+ (* closure -> func .op_array .refcount )++ ;
731
+ }
732
+
728
733
/* For fake closures, we want to reuse the static variables of the original function. */
729
734
if (!is_fake ) {
730
735
if (closure -> func .op_array .static_variables ) {
@@ -758,22 +763,17 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en
758
763
if (func -> common .scope != scope ) {
759
764
func -> common .scope = scope ;
760
765
}
761
- closure -> func .op_array .fn_flags &= ~ZEND_ACC_HEAP_RT_CACHE ;
762
766
ptr = zend_arena_alloc (& CG (arena ), func -> op_array .cache_size );
763
767
ZEND_MAP_PTR_SET (func -> op_array .run_time_cache , ptr );
768
+ closure -> func .op_array .fn_flags &= ~ZEND_ACC_HEAP_RT_CACHE ;
764
769
} else {
765
770
/* Otherwise, we use a non-shared runtime cache */
766
- closure -> func .op_array .fn_flags |= ZEND_ACC_HEAP_RT_CACHE ;
767
771
ptr = emalloc (func -> op_array .cache_size );
772
+ closure -> func .op_array .fn_flags |= ZEND_ACC_HEAP_RT_CACHE ;
768
773
}
769
774
memset (ptr , 0 , func -> op_array .cache_size );
770
775
}
771
776
ZEND_MAP_PTR_INIT (closure -> func .op_array .run_time_cache , ptr );
772
-
773
- zend_string_addref (closure -> func .op_array .function_name );
774
- if (closure -> func .op_array .refcount ) {
775
- (* closure -> func .op_array .refcount )++ ;
776
- }
777
777
} else {
778
778
memcpy (& closure -> func , func , sizeof (zend_internal_function ));
779
779
closure -> func .common .fn_flags |= ZEND_ACC_CLOSURE ;
0 commit comments