Skip to content

Commit a72a011

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix zend_observer_fcall_end_all() accessing dangling pointers
2 parents 71b55d7 + d4c07df commit a72a011

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Zend/zend_observer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ ZEND_API void ZEND_FASTCALL zend_observer_fcall_end(
238238
zend_execute_data *ex = execute_data->prev_execute_data;
239239
while (ex && (!ex->func || ex->func->type == ZEND_INTERNAL_FUNCTION
240240
|| !ZEND_OBSERVABLE_FN(ex->func->common.fn_flags)
241+
|| !&RUN_TIME_CACHE(&ex->func->op_array)
241242
|| !ZEND_OBSERVER_DATA(&ex->func->op_array)
242243
|| ZEND_OBSERVER_DATA(&ex->func->op_array) == ZEND_OBSERVER_NOT_OBSERVED)) {
243244
ex = ex->prev_execute_data;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
Bug #81430 (Attribute instantiation frame has no run time cache)
3+
--INI--
4+
memory_limit=20M
5+
zend_test.observer.enabled=1
6+
zend_test.observer.observe_all=1
7+
--FILE--
8+
<?php
9+
10+
#[\Attribute]
11+
class A {
12+
public function __construct() {}
13+
}
14+
15+
#[A]
16+
function B() {}
17+
18+
$r = new \ReflectionFunction("B");
19+
call_user_func([$r->getAttributes(A::class)[0], 'newInstance']);
20+
?>
21+
--EXPECTF--
22+
<!-- init '%s' -->
23+
<file '%s'>
24+
<!-- init A::__construct() -->
25+
<A::__construct>
26+
</A::__construct>
27+
</file '%s'>

0 commit comments

Comments
 (0)