File tree 4 files changed +38
-10
lines changed
tests/attributes/deprecated/functions
4 files changed +38
-10
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-17866 (zend_mm_heap corrupted error after upgrading from 8.4.3 to 8.4.4)
3
+ --FILE--
4
+ <?php
5
+
6
+ class Foo {
7
+ #[Deprecated("xyzzy " )]
8
+ public function __invoke () {
9
+ echo "In __invoke \n" ;
10
+ }
11
+ }
12
+
13
+ $ foo = new Foo ;
14
+ $ closure = Closure::fromCallable ($ foo );
15
+ $ test = $ closure ->__invoke (...);
16
+
17
+ $ rc = new ReflectionMethod ($ test , '__invoke ' );
18
+ var_dump ($ rc ->getAttributes ());
19
+ var_dump ($ rc ->isDeprecated ());
20
+
21
+ $ test ();
22
+
23
+ ?>
24
+ --EXPECTF--
25
+ array(1) {
26
+ [0]=>
27
+ object(ReflectionAttribute)#%d (1) {
28
+ ["name"]=>
29
+ string(10) "Deprecated"
30
+ }
31
+ }
32
+ bool(true)
33
+
34
+ Deprecated: Method Foo::__invoke() is deprecated, xyzzy in %s on line %d
35
+ In __invoke
Original file line number Diff line number Diff line change @@ -469,7 +469,7 @@ ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *object) /* {
469
469
zend_closure * closure = (zend_closure * )object ;
470
470
zend_function * invoke = (zend_function * )emalloc (sizeof (zend_function ));
471
471
const uint32_t keep_flags =
472
- ZEND_ACC_RETURN_REFERENCE | ZEND_ACC_VARIADIC | ZEND_ACC_HAS_RETURN_TYPE ;
472
+ ZEND_ACC_RETURN_REFERENCE | ZEND_ACC_VARIADIC | ZEND_ACC_HAS_RETURN_TYPE | ZEND_ACC_DEPRECATED ;
473
473
474
474
invoke -> common = closure -> func .common ;
475
475
/* We return ZEND_INTERNAL_FUNCTION, but arg_info representation is the
Original file line number Diff line number Diff line change @@ -1618,12 +1618,8 @@ ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce
1618
1618
| ZEND_ACC_PUBLIC
1619
1619
| ZEND_ACC_VARIADIC
1620
1620
| (fbc -> common .fn_flags & (ZEND_ACC_RETURN_REFERENCE |ZEND_ACC_ABSTRACT |ZEND_ACC_DEPRECATED ));
1621
- if (fbc -> common .attributes ) {
1622
- func -> attributes = fbc -> common .attributes ;
1623
- GC_TRY_ADDREF (func -> attributes );
1624
- } else {
1625
- func -> attributes = NULL ;
1626
- }
1621
+ /* Attributes outlive the trampoline because they are created by the compiler. */
1622
+ func -> attributes = fbc -> common .attributes ;
1627
1623
if (is_static ) {
1628
1624
func -> fn_flags |= ZEND_ACC_STATIC ;
1629
1625
}
Original file line number Diff line number Diff line change @@ -341,9 +341,6 @@ ZEND_API bool ZEND_FASTCALL zend_asymmetric_property_has_set_access(const zend_p
341
341
} while (0)
342
342
343
343
#define zend_free_trampoline (func ) do { \
344
- if ((func)->common.attributes) { \
345
- zend_array_release((func)->common.attributes); \
346
- } \
347
344
if ((func) == &EG(trampoline)) { \
348
345
EG(trampoline).common.attributes = NULL; \
349
346
EG(trampoline).common.function_name = NULL; \
You can’t perform that action at this time.
0 commit comments