]> granicus.if.org Git - php/commitdiff
- Enforece rule of disallowing throw in __toString()
authorMarcus Boerger <helly@php.net>
Wed, 10 May 2006 21:12:48 +0000 (21:12 +0000)
committerMarcus Boerger <helly@php.net>
Wed, 10 May 2006 21:12:48 +0000 (21:12 +0000)
Zend/zend_object_handlers.c

index 1f57ecf85117c90cd8b54aa4cb642fe8f2bf1a8f..5e2894a198406021fe2268e0c1d7c33c275d2730 100644 (file)
@@ -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)) {
-                       zval_ptr_dtor(&retval);
+                       if (retval) {
+                               zval_ptr_dtor(&retval);
+                       }
                                        zend_error(E_ERROR, "Method %s::__toString() must not throw an exception", ce->name);
                        return FAILURE;
                 }