com php-src: Fixed object to string conversion: Zend/zend_obj ect_handlers.c Zend/zend_operators.c
| From: | Dmitry Stogov | Date: | Mon, 24 Feb 2014 09:49:53 +0000 |
| Subject: | com php-src: Fixed object to string conversion: Zend/zend_obj ect_handlers.c Zend/zend_operators.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-77936@lists.php.net to get a copy of this message | ||
Commit: 1770ace2497aefa73b972aa9876cbc9a551bbb45
Author: Dmitry Stogov <dmitry@zend.com> Mon, 24 Feb 2014 13:49:53 +0400
Parents: 62e7ac77e5ba89b624be6af4f2311e1d1fc4f582
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1770ace2497aefa73b972aa9876cbc9a551bbb45
Log:
Fixed object to string conversion
Changed paths:
M Zend/zend_object_handlers.c
M Zend/zend_operators..c
Diff:
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 276f47e..11b16e1 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -1534,14 +1534,12 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj,
int ty
switch (type) {
case IS_STRING:
- ZVAL_UNDEF(&retval);
+ ZVAL_UNDEF(&retval);
ce = Z_OBJCE_P(readobj);
if (ce->__tostring &&
(zend_call_method_with_0_params(readobj, ce, &ce->__tostring, "__tostring",
&retval) || EG(exception))) {
if (UNEXPECTED(EG(exception) != NULL)) {
- if (Z_TYPE(retval) != IS_UNDEF) {
- zval_ptr_dtor(&retval);
- }
+ zval_ptr_dtor(&retval);
EG(exception) = NULL;
zend_error_noreturn(E_ERROR, "Method %s::__toString() must not throw an exception",
ce->name->val);
return FAILURE;
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 7a66f9f..8504ca5 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -343,6 +343,7 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC) /* {{{ */
#define convert_object_to_type(op, ctype, conv_func) \
if (Z_OBJ_HT_P(op)->cast_object) { \
zval dst; \
+ ZVAL_UNDEF(&dst); \
if (Z_OBJ_HT_P(op)->cast_object(op, &dst, ctype TSRMLS_CC) == FAILURE) { \
zend_error(E_RECOVERABLE_ERROR, \
"Object of class %s could not be converted to %s", Z_OBJCE_P(op)->name->val,\
@@ -1634,6 +1635,7 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /*
{
zend_free_obj_get_result(op_free TSRMLS_CC);
return ret;
} else if (Z_TYPE_P(op2) != IS_OBJECT && Z_OBJ_HT_P(op1)->cast_object) {
+ ZVAL_UNDEF(&tmp_free);
if (Z_OBJ_HT_P(op1)->cast_object(op1, &tmp_free, Z_TYPE_P(op2) TSRMLS_CC) == FAILURE)
{
ZVAL_LONG(result, 1);
zend_free_obj_get_result(&tmp_free TSRMLS_CC);
@@ -1651,6 +1653,7 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /*
{
zend_free_obj_get_result(op_free TSRMLS_CC);
return ret;
} else if (Z_TYPE_P(op1) != IS_OBJECT && Z_OBJ_HT_P(op2)->cast_object) {
+ ZVAL_UNDEF(&tmp_free);
if (Z_OBJ_HT_P(op2)->cast_object(op2, &tmp_free, Z_TYPE_P(op1) TSRMLS_CC) == FAILURE)
{
ZVAL_LONG(result, -1);
zend_free_obj_get_result(&tmp_free TSRMLS_CC);