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

index 2e0c3739fb4c4e7bb5bc13407da17116a39ab4ec..e85f4180e9b6f0000dac4e179465e1d6dfba7131 100644 (file)
@@ -1063,10 +1063,12 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty
                case IS_UNICODE:
                        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);
-                                       zend_error(E_ERROR, "Method %v::__toString() must not throw an exception", ce->name);
+                       if (retval) {
+                               zval_ptr_dtor(&retval);
+                       }
+                                       zend_error(E_ERROR, "Method %s::__toString() must not throw an exception", ce->name);
                        return FAILURE;
                 }
                                if (Z_TYPE_P(retval) == (UG(unicode)?IS_UNICODE:IS_STRING)) {