summaryrefslogtreecommitdiff
path: root/Zend/zend_execute.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-02-26 15:32:18 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-06-05 14:25:07 +0200
commita31f46421d7bf6f55dd9ac5876b8e2eacf7e0708 (patch)
tree24ffd7c5ae5e321c3994048fdd0fd9f68ae7457c /Zend/zend_execute.c
parent528aa7932a839fc6319979c34aa372805d8dc41c (diff)
downloadphp-git-a31f46421d7bf6f55dd9ac5876b8e2eacf7e0708.tar.gz
Allow exceptions in __toString()
RFC: https://wiki.php.net/rfc/tostring_exceptions And convert some object to string conversion related recoverable fatal errors into Error exceptions. Improve exception safety of internal code performing string conversions.
Diffstat (limited to 'Zend/zend_execute.c')
-rw-r--r--Zend/zend_execute.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 96d1f614e3..8adb6ef3b9 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -1549,6 +1549,12 @@ static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim,
if (Z_TYPE_P(value) != IS_STRING) {
/* Convert to string, just the time to pick the 1st byte */
zend_string *tmp = zval_get_string_func(value);
+ if (UNEXPECTED(EG(exception))) {
+ if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
+ ZVAL_UNDEF(EX_VAR(opline->result.var));
+ }
+ return;
+ }
string_len = ZSTR_LEN(tmp);
c = (zend_uchar)ZSTR_VAL(tmp)[0];
@@ -4024,6 +4030,9 @@ static zend_never_inline zend_op_array* ZEND_FASTCALL zend_include_or_eval(zval
if (Z_TYPE_P(inc_filename) != IS_STRING) {
ZVAL_STR(&tmp_inc_filename, zval_get_string_func(inc_filename));
inc_filename = &tmp_inc_filename;
+ if (UNEXPECTED(EG(exception))) {
+ return NULL;
+ }
}
switch (type) {