Skip to content

Commit 4fd9992

Browse files
committed
Fix OSS-Fuzz #403308724
Because simple hooks can be nested without starting a new context, we need to restore the old property info in case of nested hooks. Closes GH-18074.
1 parent 3bb3db5 commit 4fd9992

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ PHP NEWS
2626
(Arnaud)
2727
. Fixed bug GH-15367 (dl() of module with aliased class crashes in shutdown).
2828
(Arnaud)
29+
. Fixed OSS-Fuzz #403308724. (nielsdos)
2930

3031
- DBA:
3132
. Fixed assertion violation when opening the same file with dba_open
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
OSS-Fuzz #403308724
3+
--FILE--
4+
<?php
5+
class Base {
6+
public $y { get => 1; }
7+
}
8+
9+
class Test extends Base {
10+
public $y {
11+
get => [new class {
12+
public $inner {get => __PROPERTY__;}
13+
}, parent::$y::get()];
14+
}
15+
}
16+
17+
$test = new Test;
18+
$y = $test->y;
19+
var_dump($y);
20+
var_dump($y[0]->inner);
21+
?>
22+
--EXPECT--
23+
array(2) {
24+
[0]=>
25+
object(class@anonymous)#2 (0) {
26+
}
27+
[1]=>
28+
int(1)
29+
}
30+
string(5) "inner"

Zend/zend_compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8645,7 +8645,7 @@ static void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t f
86458645
/* FIXME: This is a dirty fix to maintain ABI compatibility. We don't
86468646
* have an actual property info yet, but we really only need the name
86478647
* anyway. We should convert this to a zend_string. */
8648-
ZEND_ASSERT(!CG(context).active_property_info);
8648+
const zend_property_info *old_active_property_info = CG(context).active_property_info;
86498649
zend_property_info dummy_prop_info = { .name = name };
86508650
CG(context).active_property_info = &dummy_prop_info;
86518651

@@ -8742,7 +8742,7 @@ static void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t f
87428742
zend_compile_attributes(&info->attributes, attr_ast, 0, ZEND_ATTRIBUTE_TARGET_PROPERTY, 0);
87438743
}
87448744

8745-
CG(context).active_property_info = NULL;
8745+
CG(context).active_property_info = old_active_property_info;
87468746
}
87478747
}
87488748
/* }}} */

0 commit comments

Comments
 (0)