Skip to content

Commit ab6977d

Browse files
committed
Fix segfault when assigning to backing value by-ref from hook
Fixes oss-fuzz #391975641 Closes GH-17620
1 parent 47a0922 commit ab6977d

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ PHP NEWS
1111
. Fixed bug GH-17618 (UnhandledMatchError does not take
1212
zend.exception_ignore_args=1 into account). (timwolla)
1313
. Fix fallback paths in fast_long_{add,sub}_function. (nielsdos)
14+
. Fixed bug OSS-Fuzz #391975641 (Crash when accessing property backing value
15+
by reference). (ilutov)
1416

1517
- DOM:
1618
. Fixed bug GH-17609 (Typo in error message: Dom\NO_DEFAULT_NS instead of

Zend/tests/oss-fuzz-391975641.phpt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
OSS-Fuzz #391975641: Segfault when creating reference from backing value
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public $prop {
8+
get => $this->prop;
9+
set {
10+
$this->prop = &$value;
11+
$value = &$this->prop;
12+
}
13+
}
14+
}
15+
16+
$c = new C;
17+
$c->prop = 1;
18+
var_dump($c->prop);
19+
20+
?>
21+
--EXPECT--
22+
int(1)

Zend/zend_execute.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3490,7 +3490,7 @@ static zend_always_inline void zend_assign_to_property_reference(zval *container
34903490

34913491
variable_ptr = zend_wrong_assign_to_variable_reference(
34923492
variable_ptr, value_ptr, &garbage OPLINE_CC EXECUTE_DATA_CC);
3493-
} else if (prop_info) {
3493+
} else if (prop_info && ZEND_TYPE_IS_SET(prop_info->type)) {
34943494
variable_ptr = zend_assign_to_typed_property_reference(prop_info, variable_ptr, value_ptr, &garbage EXECUTE_DATA_CC);
34953495
} else {
34963496
zend_assign_to_variable_reference(variable_ptr, value_ptr, &garbage);

0 commit comments

Comments
 (0)