summaryrefslogtreecommitdiff
path: root/ext/opcache/zend_file_cache.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-02-17 10:47:30 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-02-18 11:18:19 +0100
commit5d160e309ed207e618d49029e51c9c2dc2c5e61c (patch)
treea6f1deb6f582e42792a8dccedb117a26decd3e65 /ext/opcache/zend_file_cache.c
parente03284739f4a3a1052dfe5497fbf06c1b206f895 (diff)
downloadphp-git-5d160e309ed207e618d49029e51c9c2dc2c5e61c.tar.gz
Fix static variable behavior with inheritance
When a method is inherited, the static variables will now always use the initial values, rather than the values at the time of inheritance. As such, behavior no longer depends on whether inheritance happens before or after a method has been called. This is implemented by always keeping static_variables as the original values, and static_variables_ptr as the modified copy. Closes GH-6705.
Diffstat (limited to 'ext/opcache/zend_file_cache.c')
-rw-r--r--ext/opcache/zend_file_cache.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c
index 4ebb23fb84..7948797864 100644
--- a/ext/opcache/zend_file_cache.c
+++ b/ext/opcache/zend_file_cache.c
@@ -1234,12 +1234,16 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr
if (op_array->static_variables) {
ZEND_MAP_PTR_NEW(op_array->static_variables_ptr);
} else {
- ZEND_MAP_PTR_INIT(op_array->static_variables_ptr, &op_array->static_variables);
+ ZEND_MAP_PTR_INIT(op_array->static_variables_ptr, NULL);
}
ZEND_MAP_PTR_NEW(op_array->run_time_cache);
} else {
op_array->fn_flags &= ~ZEND_ACC_IMMUTABLE;
- ZEND_MAP_PTR_INIT(op_array->static_variables_ptr, &op_array->static_variables);
+ if (op_array->static_variables) {
+ ZEND_MAP_PTR_INIT(op_array->static_variables_ptr,
+ zend_arena_alloc(&CG(arena), sizeof(HashTable *)));
+ ZEND_MAP_PTR_SET(op_array->static_variables_ptr, NULL);
+ }
if (op_array != &script->script.main_op_array) {
ZEND_MAP_PTR_INIT(op_array->run_time_cache, zend_arena_alloc(&CG(arena), sizeof(void*)));
ZEND_MAP_PTR_SET(op_array->run_time_cache, NULL);