@@ -637,20 +637,26 @@ static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_sc
637
637
static void zend_persist_op_array (zval * zv )
638
638
{
639
639
zend_op_array * op_array = Z_PTR_P (zv );
640
-
640
+ zend_op_array * old_op_array ;
641
641
ZEND_ASSERT (op_array -> type == ZEND_USER_FUNCTION );
642
- op_array = Z_PTR_P (zv ) = zend_shared_memdup (Z_PTR_P (zv ), sizeof (zend_op_array ));
643
- zend_persist_op_array_ex (op_array , NULL );
644
- if (!ZCG (current_persistent_script )-> corrupted ) {
645
- op_array -> fn_flags |= ZEND_ACC_IMMUTABLE ;
646
- ZEND_MAP_PTR_NEW (op_array -> run_time_cache );
647
- if (op_array -> static_variables ) {
648
- ZEND_MAP_PTR_NEW (op_array -> static_variables_ptr );
642
+
643
+ old_op_array = zend_shared_alloc_get_xlat_entry (op_array );
644
+ if (!old_op_array ) {
645
+ op_array = Z_PTR_P (zv ) = zend_shared_memdup_put (Z_PTR_P (zv ), sizeof (zend_op_array ));
646
+ zend_persist_op_array_ex (op_array , NULL );
647
+ if (!ZCG (current_persistent_script )-> corrupted ) {
648
+ op_array -> fn_flags |= ZEND_ACC_IMMUTABLE ;
649
+ ZEND_MAP_PTR_NEW (op_array -> run_time_cache );
650
+ if (op_array -> static_variables ) {
651
+ ZEND_MAP_PTR_NEW (op_array -> static_variables_ptr );
652
+ }
653
+ } else {
654
+ ZEND_MAP_PTR_INIT (op_array -> run_time_cache , ZCG (arena_mem ));
655
+ ZCG (arena_mem ) = (void * )(((char * )ZCG (arena_mem )) + ZEND_ALIGNED_SIZE (sizeof (void * )));
656
+ ZEND_MAP_PTR_SET (op_array -> run_time_cache , NULL );
649
657
}
650
658
} else {
651
- ZEND_MAP_PTR_INIT (op_array -> run_time_cache , ZCG (arena_mem ));
652
- ZCG (arena_mem ) = (void * )(((char * )ZCG (arena_mem )) + ZEND_ALIGNED_SIZE (sizeof (void * )));
653
- ZEND_MAP_PTR_SET (op_array -> run_time_cache , NULL );
659
+ /* This can happen during preloading, if a dynamic function definition is declared. */
654
660
}
655
661
}
656
662
0 commit comments