mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Return error_zval form get_property_ptr_ptr on exception
This goes in the reverse direction of 4463acb951
.
After looking around a bit, it seems that we already check for
Z_ISERROR_P() on the get_property_ptr_ptr return value in other places.
So do this in zend_fetch_property_address() as well, and also make
sure that EG(error_zval) is indeed returned on exception in
get_property_ptr_ptr.
In particular, this fixes the duplicate exceptions that we used to
get because first get_property_ptr_ptr threw one and then
read_property throws the same exception again.
This commit is contained in:
parent
4463acb951
commit
5a076e670a
5 changed files with 8 additions and 17 deletions
|
@ -58,10 +58,5 @@ int(24)
|
|||
Fatal error: Uncaught Error: Cannot access private property B::$x in %s:%d
|
||||
Stack trace:
|
||||
#0 %s(%d): Closure->{closure}()
|
||||
#1 {main}
|
||||
|
||||
Next Error: Cannot access private property B::$x in %s:%d
|
||||
Stack trace:
|
||||
#0 %s(%d): Closure->{closure}()
|
||||
#1 {main}
|
||||
thrown in %s on line %d
|
||||
|
|
|
@ -58,10 +58,5 @@ int(24)
|
|||
Fatal error: Uncaught Error: Cannot access private property B::$x in %s:%d
|
||||
Stack trace:
|
||||
#0 %s(%d): Closure->{closure}()
|
||||
#1 {main}
|
||||
|
||||
Next Error: Cannot access private property B::$x in %s:%d
|
||||
Stack trace:
|
||||
#0 %s(%d): Closure->{closure}()
|
||||
#1 {main}
|
||||
thrown in %s on line %d
|
||||
|
|
|
@ -2822,6 +2822,9 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
|
|||
}
|
||||
return;
|
||||
}
|
||||
} else if (UNEXPECTED(Z_ISERROR_P(ptr))) {
|
||||
ZVAL_ERROR(result);
|
||||
return;
|
||||
}
|
||||
|
||||
ZVAL_INDIRECT(result, ptr);
|
||||
|
@ -2858,7 +2861,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) || EG(exception))) {
|
||||
if (UNEXPECTED(Z_ISERROR_P(variable_ptr))) {
|
||||
variable_ptr = &EG(uninitialized_zval);
|
||||
} else if (UNEXPECTED(Z_TYPE(variable) != IS_INDIRECT)) {
|
||||
zend_throw_error(NULL, "Cannot assign by reference to overloaded object");
|
||||
|
|
|
@ -1024,7 +1024,7 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int typ
|
|||
zobj = Z_OBJ_P(object);
|
||||
name = zval_try_get_tmp_string(member, &tmp_name);
|
||||
if (UNEXPECTED(!name)) {
|
||||
return NULL;
|
||||
return &EG(error_zval);
|
||||
}
|
||||
|
||||
#if DEBUG_OBJECT_HANDLERS
|
||||
|
@ -1072,6 +1072,8 @@ ZEND_API zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int typ
|
|||
zend_error(E_NOTICE, "Undefined property: %s::$%s", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name));
|
||||
}
|
||||
}
|
||||
} else if (zobj->ce->__get == NULL) {
|
||||
retval = &EG(error_zval);
|
||||
}
|
||||
|
||||
zend_tmp_string_release(tmp_name);
|
||||
|
|
|
@ -17,11 +17,7 @@ try {
|
|||
==Done==
|
||||
--EXPECTF--
|
||||
--> Access non-visible static prop like instance prop:
|
||||
Error: Cannot access protected property C::$y in %s:9
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
|
||||
Next Error: Cannot access protected property C::$y in %s:9
|
||||
Error: Cannot access protected property C::$y in %s:%d
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
==Done==
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue