@@ -689,6 +689,11 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en
689
689
closure -> func .common .fn_flags |= ZEND_ACC_CLOSURE ;
690
690
closure -> func .common .fn_flags &= ~ZEND_ACC_IMMUTABLE ;
691
691
692
+ zend_string_addref (closure -> func .op_array .function_name );
693
+ if (closure -> func .op_array .refcount ) {
694
+ (* closure -> func .op_array .refcount )++ ;
695
+ }
696
+
692
697
/* For fake closures, we want to reuse the static variables of the original function. */
693
698
if (!is_fake ) {
694
699
if (closure -> func .op_array .static_variables ) {
@@ -722,24 +727,20 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en
722
727
if (func -> common .scope != scope ) {
723
728
func -> common .scope = scope ;
724
729
}
725
- closure -> func .op_array .fn_flags &= ~ZEND_ACC_HEAP_RT_CACHE ;
726
730
ptr = zend_arena_alloc (& CG (arena ), func -> op_array .cache_size );
727
731
ZEND_MAP_PTR_SET (func -> op_array .run_time_cache , ptr );
728
732
ZEND_MAP_PTR_SET (closure -> func .op_array .run_time_cache , ptr );
733
+ closure -> func .op_array .fn_flags &= ~ZEND_ACC_HEAP_RT_CACHE ;
729
734
} else {
730
735
/* Otherwise, we use a non-shared runtime cache */
731
- closure -> func .op_array .fn_flags |= ZEND_ACC_HEAP_RT_CACHE ;
732
736
ptr = emalloc (sizeof (void * ) + func -> op_array .cache_size );
733
737
ZEND_MAP_PTR_INIT (closure -> func .op_array .run_time_cache , ptr );
734
738
ptr = (char * )ptr + sizeof (void * );
735
739
ZEND_MAP_PTR_SET (closure -> func .op_array .run_time_cache , ptr );
740
+ closure -> func .op_array .fn_flags |= ZEND_ACC_HEAP_RT_CACHE ;
736
741
}
737
742
memset (ptr , 0 , func -> op_array .cache_size );
738
743
}
739
- zend_string_addref (closure -> func .op_array .function_name );
740
- if (closure -> func .op_array .refcount ) {
741
- (* closure -> func .op_array .refcount )++ ;
742
- }
743
744
} else {
744
745
memcpy (& closure -> func , func , sizeof (zend_internal_function ));
745
746
closure -> func .common .fn_flags |= ZEND_ACC_CLOSURE ;
0 commit comments