]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.4'
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 30 Jan 2020 10:56:36 +0000 (11:56 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 30 Jan 2020 10:56:36 +0000 (11:56 +0100)
* PHP-7.4:
  Fix copying of functions in variance obligations

1  2 
Zend/zend_inheritance.c

index 60d7751e2d2b0f3786b59e7289b898587cc3360e,6bd35a6bb788d5b962ed8feda5ba67248ea04a03..9f61449b62eb64167117d6183fa2d53214452ad8
@@@ -2265,8 -2294,18 +2265,17 @@@ static void add_compatibility_obligatio
        HashTable *obligations = get_or_init_obligations_for_class(ce);
        variance_obligation *obligation = emalloc(sizeof(variance_obligation));
        obligation->type = OBLIGATION_COMPATIBILITY;
-       obligation->child_fn = *child_fn;
-       obligation->parent_fn = *parent_fn;
+       /* Copy functions, because they may be stack-allocated in the case of traits. */
+       if (child_fn->common.type == ZEND_INTERNAL_FUNCTION) {
+               memcpy(&obligation->child_fn, child_fn, sizeof(zend_internal_function));
+       } else {
+               memcpy(&obligation->child_fn, child_fn, sizeof(zend_op_array));
+       }
+       if (parent_fn->common.type == ZEND_INTERNAL_FUNCTION) {
+               memcpy(&obligation->parent_fn, parent_fn, sizeof(zend_internal_function));
+       } else {
+               memcpy(&obligation->parent_fn, parent_fn, sizeof(zend_op_array));
+       }
 -      obligation->always_error = always_error;
        zend_hash_next_index_insert_ptr(obligations, obligation);
  }