From: Nikita Popov Date: Thu, 12 Dec 2019 10:52:51 +0000 (+0100) Subject: Merge branch 'PHP-7.4' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d56768817b6c8df0f8966bd1ee1d121741631ac2;p=php Merge branch 'PHP-7.4' * PHP-7.4: Fixed bug #78950: Preloading trait method with static variables --- d56768817b6c8df0f8966bd1ee1d121741631ac2 diff --cc Zend/zend_compile.c index d95009703d,8feb13955d..311d3d2727 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@@ -1037,13 -1000,21 +1037,20 @@@ ZEND_API void function_add_ref(zend_fun if (op_array->refcount) { (*op_array->refcount)++; } - if (op_array->static_variables) { - if (!(GC_FLAGS(op_array->static_variables) & IS_ARRAY_IMMUTABLE)) { - GC_ADDREF(op_array->static_variables); - } + if (op_array->static_variables + && !(GC_FLAGS(op_array->static_variables) & IS_ARRAY_IMMUTABLE)) { + GC_ADDREF(op_array->static_variables); } - ZEND_MAP_PTR_INIT(op_array->static_variables_ptr, &op_array->static_variables); - 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); + + if (CG(compiler_options) & ZEND_COMPILE_PRELOAD) { + ZEND_ASSERT(op_array->fn_flags & ZEND_ACC_PRELOADED); + ZEND_MAP_PTR_NEW(op_array->run_time_cache); + 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->run_time_cache, zend_arena_alloc(&CG(arena), sizeof(void*))); + ZEND_MAP_PTR_SET(op_array->run_time_cache, NULL); + } } else if (function->type == ZEND_INTERNAL_FUNCTION) { if (function->common.function_name) { zend_string_addref(function->common.function_name);