Skip to content

Commit ce7d4e7

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix access to uninitialized variables in preload_load()
2 parents 02e38fe + 01e3415 commit ce7d4e7

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4524,16 +4524,6 @@ static void preload_load(size_t orig_map_ptr_static_last)
45244524
}
45254525
}
45264526

4527-
if (EG(zend_constants)) {
4528-
EG(persistent_constants_count) = EG(zend_constants)->nNumUsed;
4529-
}
4530-
if (EG(function_table)) {
4531-
EG(persistent_functions_count) = EG(function_table)->nNumUsed;
4532-
}
4533-
if (EG(class_table)) {
4534-
EG(persistent_classes_count) = EG(class_table)->nNumUsed;
4535-
}
4536-
45374527
size_t old_map_ptr_last = CG(map_ptr_last);
45384528
if (zend_map_ptr_static_last != ZCSG(map_ptr_static_last) || old_map_ptr_last != ZCSG(map_ptr_last)) {
45394529
CG(map_ptr_last) = ZCSG(map_ptr_last);
@@ -4803,6 +4793,12 @@ static zend_result accel_preload(const char *config, bool in_child)
48034793

48044794
preload_load(orig_map_ptr_static_last);
48054795

4796+
/* Update persistent counts, as shutdown will discard anything past
4797+
* that, and these tables are aliases to global ones at this point. */
4798+
EG(persistent_functions_count) = EG(function_table)->nNumUsed;
4799+
EG(persistent_classes_count) = EG(class_table)->nNumUsed;
4800+
EG(persistent_constants_count) = EG(zend_constants)->nNumUsed;
4801+
48064802
/* Store individual scripts with unlinked classes */
48074803
HANDLE_BLOCK_INTERRUPTIONS();
48084804
SHM_UNPROTECT();

0 commit comments

Comments
 (0)