@@ -2210,8 +2210,10 @@ typedef struct {
2210
2210
union {
2211
2211
zend_class_entry * dependency_ce ;
2212
2212
struct {
2213
- const zend_function * parent_fn ;
2214
- const zend_function * child_fn ;
2213
+ /* Traits may use temporary on-stack functions during inheritance checks,
2214
+ * so use copies of functions here as well. */
2215
+ zend_function parent_fn ;
2216
+ zend_function child_fn ;
2215
2217
};
2216
2218
struct {
2217
2219
const zend_property_info * parent_prop ;
@@ -2263,8 +2265,8 @@ static void add_compatibility_obligation(
2263
2265
HashTable * obligations = get_or_init_obligations_for_class (ce );
2264
2266
variance_obligation * obligation = emalloc (sizeof (variance_obligation ));
2265
2267
obligation -> type = OBLIGATION_COMPATIBILITY ;
2266
- obligation -> child_fn = child_fn ;
2267
- obligation -> parent_fn = parent_fn ;
2268
+ obligation -> child_fn = * child_fn ;
2269
+ obligation -> parent_fn = * parent_fn ;
2268
2270
zend_hash_next_index_insert_ptr (obligations , obligation );
2269
2271
}
2270
2272
@@ -2293,13 +2295,13 @@ static int check_variance_obligation(zval *zv) {
2293
2295
}
2294
2296
} else if (obligation -> type == OBLIGATION_COMPATIBILITY ) {
2295
2297
inheritance_status status = zend_do_perform_implementation_check (
2296
- obligation -> child_fn , obligation -> parent_fn );
2298
+ & obligation -> child_fn , & obligation -> parent_fn );
2297
2299
if (UNEXPECTED (status != INHERITANCE_SUCCESS )) {
2298
2300
if (EXPECTED (status == INHERITANCE_UNRESOLVED )) {
2299
2301
return ZEND_HASH_APPLY_KEEP ;
2300
2302
}
2301
2303
ZEND_ASSERT (status == INHERITANCE_ERROR );
2302
- emit_incompatible_method_error (obligation -> child_fn , obligation -> parent_fn , status );
2304
+ emit_incompatible_method_error (& obligation -> child_fn , & obligation -> parent_fn , status );
2303
2305
}
2304
2306
/* Either the compatibility check was successful or only threw a warning. */
2305
2307
} else {
@@ -2366,10 +2368,10 @@ static void report_variance_errors(zend_class_entry *ce) {
2366
2368
/* Just used to populate the delayed_autoloads table,
2367
2369
* which will be used when printing the "unresolved" error. */
2368
2370
inheritance_status status = zend_do_perform_implementation_check (
2369
- obligation -> child_fn , obligation -> parent_fn );
2371
+ & obligation -> child_fn , & obligation -> parent_fn );
2370
2372
ZEND_ASSERT (status == INHERITANCE_UNRESOLVED );
2371
2373
emit_incompatible_method_error (
2372
- obligation -> child_fn , obligation -> parent_fn , status );
2374
+ & obligation -> child_fn , & obligation -> parent_fn , status );
2373
2375
} else if (obligation -> type == OBLIGATION_PROPERTY_COMPATIBILITY ) {
2374
2376
emit_incompatible_property_error (obligation -> child_prop , obligation -> parent_prop );
2375
2377
} else {
0 commit comments