diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index 59befde732194..9ec444e4c75e3 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -409,8 +409,11 @@ static void zend_enum_register_func(zend_class_entry *ce, zend_known_string_id n zif->module = EG(current_module); zif->scope = ce; zif->T = ZEND_OBSERVER_ENABLED; - ZEND_MAP_PTR_NEW(zif->run_time_cache); - ZEND_MAP_PTR_SET(zif->run_time_cache, zend_arena_alloc(&CG(arena), zend_internal_run_time_cache_reserved_size())); + if (EG(active)) { // at run-time: this ought to only happen if registered with dl() or somehow temporarily at runtime + ZEND_MAP_PTR_INIT(zif->run_time_cache, zend_arena_alloc(&CG(arena), zend_internal_run_time_cache_reserved_size())); + } else { + ZEND_MAP_PTR_NEW(zif->run_time_cache); + } if (!zend_hash_add_ptr(&ce->function_table, name, zif)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot redeclare %s::%s()", ZSTR_VAL(ce->name), ZSTR_VAL(name));