Skip to content

Commit d4c07df

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix zend_observer_fcall_end_all() accessing dangling pointers
2 parents f82593d + 76e2a83 commit d4c07df

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ PHP NEWS
1414
. Fixed bug GH-7757 (Multi-inherited final constant causes fatal error).
1515
(cmb)
1616
. Fixed zend_fibers.c build with ZEND_FIBER_UCONTEXT. (Petr Sumbera)
17+
. Fixed zend_observer_fcall_end_all() accessing dangling pointers. (Florian
18+
Sowade)
1719

1820
- Filter:
1921
. Fixed FILTER_FLAG_NO_RES_RANGE flag. (Yifan Tong)

Zend/zend_observer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ ZEND_API void ZEND_FASTCALL zend_observer_fcall_end(
236236
zend_execute_data *ex = execute_data->prev_execute_data;
237237
while (ex && (!ex->func || ex->func->type == ZEND_INTERNAL_FUNCTION
238238
|| !ZEND_OBSERVABLE_FN(ex->func->common.fn_flags)
239+
|| !&RUN_TIME_CACHE(&ex->func->op_array)
239240
|| !ZEND_OBSERVER_DATA(&ex->func->op_array)
240241
|| ZEND_OBSERVER_DATA(&ex->func->op_array) == ZEND_OBSERVER_NOT_OBSERVED)) {
241242
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)