@@ -732,6 +732,11 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en
732732 closure -> func .common .fn_flags |= ZEND_ACC_CLOSURE ;
733733 closure -> func .common .fn_flags &= ~ZEND_ACC_IMMUTABLE ;
734734
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+
735740 /* For fake closures, we want to reuse the static variables of the original function. */
736741 if (!is_fake ) {
737742 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
765770 if (func -> common .scope != scope ) {
766771 func -> common .scope = scope ;
767772 }
768- closure -> func .op_array .fn_flags &= ~ZEND_ACC_HEAP_RT_CACHE ;
769773 ptr = zend_arena_alloc (& CG (arena ), func -> op_array .cache_size );
770774 ZEND_MAP_PTR_SET (func -> op_array .run_time_cache , ptr );
775+ closure -> func .op_array .fn_flags &= ~ZEND_ACC_HEAP_RT_CACHE ;
771776 } else {
772777 /* Otherwise, we use a non-shared runtime cache */
773- closure -> func .op_array .fn_flags |= ZEND_ACC_HEAP_RT_CACHE ;
774778 ptr = emalloc (func -> op_array .cache_size );
779+ closure -> func .op_array .fn_flags |= ZEND_ACC_HEAP_RT_CACHE ;
775780 }
776781 memset (ptr , 0 , func -> op_array .cache_size );
777782 }
778783 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- }
784784 } else {
785785 memcpy (& closure -> func , func , sizeof (zend_internal_function ));
786786 closure -> func .common .fn_flags |= ZEND_ACC_CLOSURE ;
0 commit comments