From 8fd7f02ea4cd595a792ef37e558d357d97bceefa Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 31 Mar 2020 12:17:32 +0200 Subject: Make cast_object handler required Avoid subtle differences in behavior depending on whether the handler is absent or returns FAILURE. If you previously set cast_object to NULL, create a handler that always returns FAILURE instead. --- Zend/zend_API.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'Zend/zend_API.c') diff --git a/Zend/zend_API.c b/Zend/zend_API.c index acb4366527..00b8076b3d 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -472,15 +472,12 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest *dest = Z_STR_P(arg); } else if (UNEXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) { zend_object *zobj = Z_OBJ_P(arg); - - if (Z_OBJ_HANDLER_P(arg, cast_object)) { - zval obj; - if (zobj->handlers->cast_object(zobj, &obj, IS_STRING) == SUCCESS) { - OBJ_RELEASE(zobj); - ZVAL_COPY_VALUE(arg, &obj); - *dest = Z_STR_P(arg); - return 1; - } + zval obj; + if (zobj->handlers->cast_object(zobj, &obj, IS_STRING) == SUCCESS) { + OBJ_RELEASE(zobj); + ZVAL_COPY_VALUE(arg, &obj); + *dest = Z_STR_P(arg); + return 1; } return 0; } else { -- cgit v1.2.1