summaryrefslogtreecommitdiff
path: root/Zend/zend_operators.c
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/zend_operators.c')
-rw-r--r--Zend/zend_operators.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 896f6dcbe1..3660671396 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -607,14 +607,15 @@ try_again:
ZEND_API zend_bool ZEND_FASTCALL _try_convert_to_string(zval *op)
{
- if (Z_TYPE_P(op) != IS_STRING) {
- zend_string *str = zval_get_string_func(op);
- if (UNEXPECTED(EG(exception))) {
- return 0;
- }
- zval_ptr_dtor(op);
- ZVAL_STR(op, str);
+ zend_string *str;
+
+ ZEND_ASSERT(Z_TYPE_P(op) != IS_STRING);
+ str = zval_try_get_string_func(op);
+ if (UNEXPECTED(!str)) {
+ return 0;
}
+ zval_ptr_dtor(op);
+ ZVAL_STR(op, str);
return 1;
}
@@ -865,7 +866,7 @@ try_again:
}
/* }}} */
-ZEND_API zend_string* ZEND_FASTCALL zval_get_string_func(zval *op) /* {{{ */
+static zend_always_inline zend_string* __zval_get_string_func(zval *op, zend_bool try) /* {{{ */
{
try_again:
switch (Z_TYPE_P(op)) {
@@ -896,7 +897,7 @@ try_again:
} else if (Z_OBJ_HT_P(op)->get) {
zval *z = Z_OBJ_HT_P(op)->get(op, &tmp);
if (Z_TYPE_P(z) != IS_OBJECT) {
- zend_string *str = zval_get_string(z);
+ zend_string *str = try ? zval_try_get_string(z) : zval_get_string(z);
zval_ptr_dtor(z);
return str;
}
@@ -905,7 +906,7 @@ try_again:
if (!EG(exception)) {
zend_throw_error(NULL, "Object of class %s could not be converted to string", ZSTR_VAL(Z_OBJCE_P(op)->name));
}
- return ZSTR_EMPTY_ALLOC();
+ return try ? NULL : ZSTR_EMPTY_ALLOC();
}
case IS_REFERENCE:
op = Z_REFVAL_P(op);
@@ -918,13 +919,15 @@ try_again:
}
/* }}} */
+ZEND_API zend_string* ZEND_FASTCALL zval_get_string_func(zval *op) /* {{{ */
+{
+ return __zval_get_string_func(op, 0);
+}
+/* }}} */
+
ZEND_API zend_string* ZEND_FASTCALL zval_try_get_string_func(zval *op) /* {{{ */
{
- zend_string *str = zval_get_string_func(op);
- if (UNEXPECTED(EG(exception))) {
- return NULL;
- }
- return str;
+ return __zval_get_string_func(op, 1);
}
/* }}} */