mirror of
https://github.com/php/php-src.git
synced 2024-12-03 23:05:57 +08:00
Explicitly check for exceptions in by-ref obj prop assign
Relying on setting ERROR if an exception happened during the property address fetch is both a bit fragile and may pessimize other codepaths that will check for exceptions in the VM. Adding an extra exception check instead, which should also allow us to drop the use of ERROR in this area in master.
This commit is contained in:
parent
12f4e9e020
commit
4463acb951
@ -2858,7 +2858,7 @@ static zend_always_inline void zend_assign_to_property_reference(zval *container
|
||||
variable_ptr = Z_INDIRECT_P(variable_ptr);
|
||||
}
|
||||
|
||||
if (UNEXPECTED(Z_ISERROR_P(variable_ptr))) {
|
||||
if (UNEXPECTED(Z_ISERROR_P(variable_ptr) || EG(exception))) {
|
||||
variable_ptr = &EG(uninitialized_zval);
|
||||
} else if (UNEXPECTED(Z_TYPE(variable) != IS_INDIRECT)) {
|
||||
zend_throw_error(NULL, "Cannot assign by reference to overloaded object");
|
||||
|
@ -8,17 +8,20 @@ class C {
|
||||
$c = new C;
|
||||
|
||||
echo "\n--> Access non-visible static prop like instance prop:\n";
|
||||
$c->y =& $ref;
|
||||
try {
|
||||
$c->y =& $ref;
|
||||
} catch (Error $e) {
|
||||
echo $e, "\n";
|
||||
}
|
||||
?>
|
||||
==Done==
|
||||
--EXPECTF--
|
||||
--> Access non-visible static prop like instance prop:
|
||||
|
||||
Fatal error: Uncaught Error: Cannot access protected property C::$y in %s:8
|
||||
Error: Cannot access protected property C::$y in %s:9
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
|
||||
Next Error: Cannot access protected property C::$y in %s:8
|
||||
Next Error: Cannot access protected property C::$y in %s:9
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in %s on line 8
|
||||
==Done==
|
||||
|
Loading…
Reference in New Issue
Block a user