Skip to content

Commit e560592

Browse files
Petar Obradovićbwoebi
Petar Obradović
authored andcommitted
Fix GH-9675: Re-adjust run_time_cache init for internal enum methods
Closes GH-10143.
1 parent 757e269 commit e560592

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ PHP NEWS
1010
unpacked array). (Arnaud)
1111
. Fix GH-9735 (Fiber stack variables do not participate in cycle collector).
1212
(Arnaud)
13+
. Fix GH-9675 (Broken run_time_cache init for internal enum methods).
14+
(Petar Obradović, Bob)
1315

1416
- FPM:
1517
. Fixed bug #77106 (Missing separator in FPM FastCGI errors). (Jakub Zelenka)

Zend/zend_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2714,7 +2714,7 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend
27142714
internal_function->prototype = NULL;
27152715
internal_function->attributes = NULL;
27162716
if (EG(active)) { // at run-time: this ought to only happen if registered with dl() or somehow temporarily at runtime
2717-
ZEND_MAP_PTR_INIT(internal_function->run_time_cache, zend_arena_alloc(&CG(arena), zend_internal_run_time_cache_reserved_size()));
2717+
ZEND_MAP_PTR_INIT(internal_function->run_time_cache, zend_arena_calloc(&CG(arena), 1, zend_internal_run_time_cache_reserved_size()));
27182718
} else {
27192719
ZEND_MAP_PTR_NEW(internal_function->run_time_cache);
27202720
}

Zend/zend_enum.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,11 @@ static void zend_enum_register_func(zend_class_entry *ce, zend_known_string_id n
409409
zif->module = EG(current_module);
410410
zif->scope = ce;
411411
zif->T = ZEND_OBSERVER_ENABLED;
412-
ZEND_MAP_PTR_NEW(zif->run_time_cache);
413-
ZEND_MAP_PTR_SET(zif->run_time_cache, zend_arena_alloc(&CG(arena), zend_internal_run_time_cache_reserved_size()));
412+
if (EG(active)) { // at run-time
413+
ZEND_MAP_PTR_INIT(zif->run_time_cache, zend_arena_calloc(&CG(arena), 1, zend_internal_run_time_cache_reserved_size()));
414+
} else {
415+
ZEND_MAP_PTR_NEW(zif->run_time_cache);
416+
}
414417

415418
if (!zend_hash_add_ptr(&ce->function_table, name, zif)) {
416419
zend_error_noreturn(E_COMPILE_ERROR, "Cannot redeclare %s::%s()", ZSTR_VAL(ce->name), ZSTR_VAL(name));

0 commit comments

Comments
 (0)