mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
- Enforece rule of disallowing throw in __toString()
This commit is contained in:
parent
cbb11e018a
commit
f16bdce284
1 changed files with 4 additions and 2 deletions
|
@ -1034,9 +1034,11 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty
|
|||
case IS_STRING:
|
||||
ce = Z_OBJCE_P(readobj);
|
||||
if (ce->__tostring &&
|
||||
zend_call_method_with_0_params(&readobj, ce, &ce->__tostring, "__tostring", &retval)) {
|
||||
(zend_call_method_with_0_params(&readobj, ce, &ce->__tostring, "__tostring", &retval) || EG(exception))) {
|
||||
if (EG(exception)) {
|
||||
if (retval) {
|
||||
zval_ptr_dtor(&retval);
|
||||
}
|
||||
zend_error(E_ERROR, "Method %s::__toString() must not throw an exception", ce->name);
|
||||
return FAILURE;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue