diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-01-02 14:56:39 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-01-02 14:56:39 +0100 |
commit | 36d5fbbd6bceb1e0e1130bb1fff07a702d548594 (patch) | |
tree | dba4e23959bfba72ea6f24a0a614f9f2f5b01b63 | |
parent | e576d342bb8a4e8078a52383ed360acf00aefd39 (diff) | |
download | php-git-36d5fbbd6bceb1e0e1130bb1fff07a702d548594.tar.gz |
Fix file cache run_time_cache unserialization
If the script was serialized as file_cache_only (thus non-immutable)
and then gets unserialized into SHM, we need to allocate a new
run_time_cache slot and can't use the serialized arena pointer.
-rw-r--r-- | ext/opcache/zend_file_cache.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c index 6d49b8b950..6b8ef20434 100644 --- a/ext/opcache/zend_file_cache.c +++ b/ext/opcache/zend_file_cache.c @@ -1237,7 +1237,15 @@ static void zend_file_cache_unserialize_op_array(zend_op_array *op_arr ZEND_MAP_PTR_NEW(op_array->run_time_cache); } else { ZEND_MAP_PTR_INIT(op_array->static_variables_ptr, &op_array->static_variables); - UNSERIALIZE_PTR(ZEND_MAP_PTR(op_array->run_time_cache)); + if (ZEND_MAP_PTR(op_array->run_time_cache)) { + if (script->corrupted) { + /* Not in SHM: Use serialized arena pointer. */ + UNSERIALIZE_PTR(ZEND_MAP_PTR(op_array->run_time_cache)); + } else { + /* In SHM: Allocate new pointer. */ + ZEND_MAP_PTR_NEW(op_array->run_time_cache); + } + } } } } |