summaryrefslogtreecommitdiff
path: root/Zend/zend_inheritance.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-01-28 10:44:37 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-01-28 10:44:37 +0100
commit3bae1793abfaf03f625f4d1d0c38d125627147e9 (patch)
treea293c5b2f855e1b844eb55d7066d2b8cf101dd29 /Zend/zend_inheritance.c
parent9a5ea0de69512da23e63b7a4f8fcadc96f7a9886 (diff)
parent1146bdb9b21cdf725dd5ea8882221356779926b6 (diff)
downloadphp-git-3bae1793abfaf03f625f4d1d0c38d125627147e9.tar.gz
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed bug #78989
Diffstat (limited to 'Zend/zend_inheritance.c')
-rw-r--r--Zend/zend_inheritance.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 3a9deabb06..60d7751e2d 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -2210,8 +2210,10 @@ typedef struct {
union {
zend_class_entry *dependency_ce;
struct {
- const zend_function *parent_fn;
- const zend_function *child_fn;
+ /* Traits may use temporary on-stack functions during inheritance checks,
+ * so use copies of functions here as well. */
+ zend_function parent_fn;
+ zend_function child_fn;
};
struct {
const zend_property_info *parent_prop;
@@ -2263,8 +2265,8 @@ static void add_compatibility_obligation(
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;
+ obligation->child_fn = *child_fn;
+ obligation->parent_fn = *parent_fn;
zend_hash_next_index_insert_ptr(obligations, obligation);
}
@@ -2293,13 +2295,13 @@ static int check_variance_obligation(zval *zv) {
}
} else if (obligation->type == OBLIGATION_COMPATIBILITY) {
inheritance_status status = zend_do_perform_implementation_check(
- obligation->child_fn, obligation->parent_fn);
+ &obligation->child_fn, &obligation->parent_fn);
if (UNEXPECTED(status != INHERITANCE_SUCCESS)) {
if (EXPECTED(status == INHERITANCE_UNRESOLVED)) {
return ZEND_HASH_APPLY_KEEP;
}
ZEND_ASSERT(status == INHERITANCE_ERROR);
- emit_incompatible_method_error(obligation->child_fn, obligation->parent_fn, status);
+ emit_incompatible_method_error(&obligation->child_fn, &obligation->parent_fn, status);
}
/* Either the compatibility check was successful or only threw a warning. */
} else {
@@ -2366,10 +2368,10 @@ static void report_variance_errors(zend_class_entry *ce) {
/* Just used to populate the delayed_autoloads table,
* which will be used when printing the "unresolved" error. */
inheritance_status status = zend_do_perform_implementation_check(
- obligation->child_fn, obligation->parent_fn);
+ &obligation->child_fn, &obligation->parent_fn);
ZEND_ASSERT(status == INHERITANCE_UNRESOLVED);
emit_incompatible_method_error(
- obligation->child_fn, obligation->parent_fn, status);
+ &obligation->child_fn, &obligation->parent_fn, status);
} else if (obligation->type == OBLIGATION_PROPERTY_COMPATIBILITY) {
emit_incompatible_property_error(obligation->child_prop, obligation->parent_prop);
} else {