Skip to content

Commit 27807fd

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix access to uninitialized variables in preload_load()
2 parents da7558a + ab9d121 commit 27807fd

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ PHP NEWS
1313
. Fixed bug GH-19974 (fpm_status_export_to_zval segfault for parallel
1414
execution). (Jakub Zelenka, txuna)
1515

16+
- Opcache:
17+
. Fixed bug GH-20081 (access to uninitialized vars in preload_load()).
18+
(Arnaud)
19+
1620
- Random:
1721
. Fix Randomizer::__serialize() w.r.t. INDIRECTs. (nielsdos)
1822

ext/opcache/ZendAccelerator.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4443,16 +4443,6 @@ static void preload_load(size_t orig_map_ptr_static_last)
44434443
}
44444444
}
44454445

4446-
if (EG(zend_constants)) {
4447-
EG(persistent_constants_count) = EG(zend_constants)->nNumUsed;
4448-
}
4449-
if (EG(function_table)) {
4450-
EG(persistent_functions_count) = EG(function_table)->nNumUsed;
4451-
}
4452-
if (EG(class_table)) {
4453-
EG(persistent_classes_count) = EG(class_table)->nNumUsed;
4454-
}
4455-
44564446
size_t old_map_ptr_last = CG(map_ptr_last);
44574447
if (zend_map_ptr_static_last != ZCSG(map_ptr_static_last) || old_map_ptr_last != ZCSG(map_ptr_last)) {
44584448
CG(map_ptr_last) = ZCSG(map_ptr_last);
@@ -4722,6 +4712,12 @@ static zend_result accel_preload(const char *config, bool in_child)
47224712

47234713
preload_load(orig_map_ptr_static_last);
47244714

4715+
/* Update persistent counts, as shutdown will discard anything past
4716+
* that, and these tables are aliases to global ones at this point. */
4717+
EG(persistent_functions_count) = EG(function_table)->nNumUsed;
4718+
EG(persistent_classes_count) = EG(class_table)->nNumUsed;
4719+
EG(persistent_constants_count) = EG(zend_constants)->nNumUsed;
4720+
47254721
/* Store individual scripts with unlinked classes */
47264722
HANDLE_BLOCK_INTERRUPTIONS();
47274723
SHM_UNPROTECT();

0 commit comments

Comments
 (0)