From b2d78ae00cd462aefef3eb83525e0e24d82ef2b4 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Mon, 19 May 2025 19:37:34 +0200 Subject: [PATCH] Backport accel_globals->key leak fix (8.3) Closes GH-18602. --- NEWS | 1 + ext/opcache/ZendAccelerator.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 0e3b53db3c2..e9c47a74a35 100644 --- a/NEWS +++ b/NEWS @@ -34,6 +34,7 @@ PHP NEWS memory_consumption or jit_buffer_size). (nielsdos) . Fixed bug GH-18567 (Preloading with internal class alias triggers assertion failure). (nielsdos) + . Fix leak of accel_globals->key. (nielsdos) - PDO_OCI: . Fixed bug GH-18494 (PDO OCI segfault in statement GC). (nielsdos) diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 47e0bc08bd5..bd6b323871b 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -2937,12 +2937,10 @@ static void accel_globals_ctor(zend_accel_globals *accel_globals) GC_MAKE_PERSISTENT_LOCAL(accel_globals->key); } -#ifdef ZTS static void accel_globals_dtor(zend_accel_globals *accel_globals) { zend_string_free(accel_globals->key); } -#endif #ifdef HAVE_HUGE_CODE_PAGES # ifndef _WIN32 @@ -3384,6 +3382,8 @@ void accel_shutdown(void) if (!ZCG(enabled) || !accel_startup_ok) { #ifdef ZTS ts_free_id(accel_globals_id); +#else + accel_globals_dtor(&accel_globals); #endif return; } @@ -3398,6 +3398,8 @@ void accel_shutdown(void) #ifdef ZTS ts_free_id(accel_globals_id); +#else + accel_globals_dtor(&accel_globals); #endif if (!_file_cache_only) {