]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.4'
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 12 Dec 2019 10:52:51 +0000 (11:52 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 12 Dec 2019 10:52:51 +0000 (11:52 +0100)
* PHP-7.4:
  Fixed bug #78950: Preloading trait method with static variables

1  2 
Zend/zend_compile.c

index d95009703d286e7be308e78f1f14c1acf7081d9a,8feb13955ded1465c3db3377d1c58a5f92dd1e61..311d3d27279bf93e25c55e89d7fb18ec2424fb70
@@@ -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);