@@ -725,6 +725,11 @@ static void zend_create_closure_ex(zval *res, zend_function *func, zend_class_en
725725 closure -> func .common .fn_flags |= ZEND_ACC_CLOSURE ;
726726 closure -> func .common .fn_flags &= ~ZEND_ACC_IMMUTABLE ;
727727
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+
728733 /* For fake closures, we want to reuse the static variables of the original function. */
729734 if (!is_fake ) {
730735 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
758763 if (func -> common .scope != scope ) {
759764 func -> common .scope = scope ;
760765 }
761- closure -> func .op_array .fn_flags &= ~ZEND_ACC_HEAP_RT_CACHE ;
762766 ptr = zend_arena_alloc (& CG (arena ), func -> op_array .cache_size );
763767 ZEND_MAP_PTR_SET (func -> op_array .run_time_cache , ptr );
768+ closure -> func .op_array .fn_flags &= ~ZEND_ACC_HEAP_RT_CACHE ;
764769 } else {
765770 /* Otherwise, we use a non-shared runtime cache */
766- closure -> func .op_array .fn_flags |= ZEND_ACC_HEAP_RT_CACHE ;
767771 ptr = emalloc (func -> op_array .cache_size );
772+ closure -> func .op_array .fn_flags |= ZEND_ACC_HEAP_RT_CACHE ;
768773 }
769774 memset (ptr , 0 , func -> op_array .cache_size );
770775 }
771776 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- }
777777 } else {
778778 memcpy (& closure -> func , func , sizeof (zend_internal_function ));
779779 closure -> func .common .fn_flags |= ZEND_ACC_CLOSURE ;
0 commit comments