diff --git a/Zend/tests/attributes/deprecated/functions/gh17866.phpt b/Zend/tests/attributes/deprecated/functions/gh17866.phpt new file mode 100644 index 0000000000000..d1e9171cc832e --- /dev/null +++ b/Zend/tests/attributes/deprecated/functions/gh17866.phpt @@ -0,0 +1,33 @@ +--TEST-- +GH-17866 (zend_mm_heap corrupted error after upgrading from 8.4.3 to 8.4.4) +--FILE-- +__invoke(...); + +$rc = new ReflectionMethod($test, '__invoke'); +var_dump($rc->getAttributes()); + +$test(); + +?> +--EXPECTF-- +array(1) { + [0]=> + object(ReflectionAttribute)#%d (1) { + ["name"]=> + string(10) "Deprecated" + } +} + +Deprecated: Method Foo::__invoke() is deprecated, xyzzy in %s on line %d +In __invoke diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 629aa7d51a840..c3a06ad7360f2 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -467,6 +467,11 @@ ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *object) /* { ZEND_ACC_RETURN_REFERENCE | ZEND_ACC_VARIADIC | ZEND_ACC_HAS_RETURN_TYPE; invoke->common = closure->func.common; + + if (invoke->common.attributes) { + GC_TRY_ADDREF(invoke->common.attributes); + } + /* We return ZEND_INTERNAL_FUNCTION, but arg_info representation is the * same as for ZEND_USER_FUNCTION (uses zend_string* instead of char*). * This is not a problem, because ZEND_ACC_HAS_TYPE_HINTS is never set,