Skip to content

Commit eee1617

Browse files
committed
Tweak behaviour of dynamic properties wrt error handlers
With the fix in #12114, the behaviour would change for non-dynamic properties. Align the behaviour for dynamic properties to be the same. Closes GH-12117.
1 parent 6b74f1f commit eee1617

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Zend/tests/oss_fuzz_61712b.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
OSS-Fuzz #61712 (assertion failure with error handler during binary op)
3+
--FILE--
4+
<?php
5+
#[AllowDynamicProperties]
6+
class C {
7+
function error($_, $msg) {
8+
echo $msg, "\n";
9+
$this->a = 12345;
10+
}
11+
}
12+
13+
$c = new C;
14+
set_error_handler([$c, 'error']);
15+
$c->a %= 10;
16+
var_dump($c->a);
17+
?>
18+
--EXPECT--
19+
Undefined property: C::$a
20+
int(5)

Zend/zend_object_handlers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zend_object *zobj, zend_string *nam
11631163
if (UNEXPECTED(type == BP_VAR_RW || type == BP_VAR_R)) {
11641164
zend_error(E_WARNING, "Undefined property: %s::$%s", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
11651165
}
1166-
retval = zend_hash_update(zobj->properties, name, &EG(uninitialized_zval));
1166+
retval = zend_hash_add(zobj->properties, name, &EG(uninitialized_zval));
11671167
}
11681168
} else if (zobj->ce->__get == NULL) {
11691169
retval = &EG(error_zval);

0 commit comments

Comments
 (0)