]> granicus.if.org Git - php/commitdiff
return empty string of correct type if __toString() returned invalid value
authorAntony Dovgal <tony2001@php.net>
Mon, 17 Mar 2008 15:05:28 +0000 (15:05 +0000)
committerAntony Dovgal <tony2001@php.net>
Mon, 17 Mar 2008 15:05:28 +0000 (15:05 +0000)
Zend/zend_object_handlers.c

index 04f0a62ea65ddc00a1c68f0b9dd9a51b3940a142..21c77f382499c350e1e678b0de53f0aaed67e8a0 100644 (file)
@@ -1260,7 +1260,11 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty
                                        if (readobj == writeobj) {
                                                zval_dtor(readobj);
                                        }
-                                       ZVAL_EMPTY_STRING(writeobj);
+                                       if (type == IS_UNICODE) {
+                                               ZVAL_EMPTY_UNICODE(writeobj);
+                                       } else {
+                                               ZVAL_EMPTY_STRING(writeobj);
+                                       }
                                        zend_error(E_RECOVERABLE_ERROR, "Method %v::__toString() must return a string value", ce->name);
                                        return SUCCESS;
                                }