From a5d0c1e21b9fa166d8fe5ec7d52a24a5f7adc107 Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Tue, 21 Aug 2012 23:21:59 +0200 Subject: Fix handling of several uinitialized intl objects --- ext/intl/msgformat/msgformat_class.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'ext/intl/msgformat/msgformat_class.c') diff --git a/ext/intl/msgformat/msgformat_class.c b/ext/intl/msgformat/msgformat_class.c index 7ed28df3dc..9cccef2709 100644 --- a/ext/intl/msgformat/msgformat_class.c +++ b/ext/intl/msgformat/msgformat_class.c @@ -24,6 +24,8 @@ #include "msgformat.h" #include "msgformat_attr.h" +#include + zend_class_entry *MessageFormatter_ce_ptr = NULL; static zend_object_handlers MessageFormatter_handlers; @@ -80,18 +82,24 @@ zend_object_value MessageFormatter_object_clone(zval *object TSRMLS_DC) zend_object_handle handle = Z_OBJ_HANDLE_P(object); MessageFormatter_object *mfo, *new_mfo; - MSG_FORMAT_METHOD_FETCH_OBJECT; + MSG_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; new_obj_val = MessageFormatter_ce_ptr->create_object(MessageFormatter_ce_ptr TSRMLS_CC); new_mfo = (MessageFormatter_object *)zend_object_store_get_object_by_handle(new_obj_val.handle TSRMLS_CC); /* clone standard parts */ zend_objects_clone_members(&new_mfo->zo, new_obj_val, &mfo->zo, handle TSRMLS_CC); + /* clone formatter object */ - MSG_FORMAT_OBJECT(new_mfo) = umsg_clone(MSG_FORMAT_OBJECT(mfo), &INTL_DATA_ERROR_CODE(new_mfo)); - if(U_FAILURE(INTL_DATA_ERROR_CODE(new_mfo))) { - /* set up error in case error handler is interested */ - intl_error_set( NULL, INTL_DATA_ERROR_CODE(new_mfo), "Failed to clone MessageFormatter object", 0 TSRMLS_CC ); - MessageFormatter_object_dtor(new_mfo, new_obj_val.handle TSRMLS_CC); /* free new object */ - zend_error(E_ERROR, "Failed to clone MessageFormatter object"); + if (MSG_FORMAT_OBJECT(mfo) != NULL) { + MSG_FORMAT_OBJECT(new_mfo) = umsg_clone(MSG_FORMAT_OBJECT(mfo), + &INTL_DATA_ERROR_CODE(mfo)); + + if (U_FAILURE(INTL_DATA_ERROR_CODE(mfo))) { + intl_errors_set(INTL_DATA_ERROR_P(mfo), INTL_DATA_ERROR_CODE(mfo), + "Failed to clone MessageFormatter object", 0 TSRMLS_CC); + zend_throw_exception_ex(NULL, 0, "Failed to clone MessageFormatter object"); + } + } else { + zend_throw_exception_ex(NULL, 0, "Cannot clone unconstructed MessageFormatter"); } return new_obj_val; } -- cgit v1.2.1 From eca4fc69918c856966298435bd1133e55a3c8e58 Mon Sep 17 00:00:00 2001 From: Anatoliy Belsky Date: Thu, 23 Aug 2012 13:32:06 +0200 Subject: ZTS fix introduced by Felipe must also go into 5.3 --- ext/intl/msgformat/msgformat_class.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ext/intl/msgformat/msgformat_class.c') diff --git a/ext/intl/msgformat/msgformat_class.c b/ext/intl/msgformat/msgformat_class.c index 9cccef2709..36d06d2d36 100644 --- a/ext/intl/msgformat/msgformat_class.c +++ b/ext/intl/msgformat/msgformat_class.c @@ -96,10 +96,10 @@ zend_object_value MessageFormatter_object_clone(zval *object TSRMLS_DC) if (U_FAILURE(INTL_DATA_ERROR_CODE(mfo))) { intl_errors_set(INTL_DATA_ERROR_P(mfo), INTL_DATA_ERROR_CODE(mfo), "Failed to clone MessageFormatter object", 0 TSRMLS_CC); - zend_throw_exception_ex(NULL, 0, "Failed to clone MessageFormatter object"); + zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Failed to clone MessageFormatter object"); } } else { - zend_throw_exception_ex(NULL, 0, "Cannot clone unconstructed MessageFormatter"); + zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Cannot clone unconstructed MessageFormatter"); } return new_obj_val; } -- cgit v1.2.1 From 0410b4e60f6b4b3a105c0866b797dc47a58ec594 Mon Sep 17 00:00:00 2001 From: Gustavo Lopes Date: Sun, 26 Aug 2012 23:37:09 +0200 Subject: Fixed defective cloning in ext/intl classes See also bug #62915 Cherry picked from 886a50a (I forgot about 5.3) Conflicts: ext/intl/spoofchecker/spoofchecker_class.c ext/intl/transliterator/transliterator_class.c --- ext/intl/msgformat/msgformat_class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/intl/msgformat/msgformat_class.c') diff --git a/ext/intl/msgformat/msgformat_class.c b/ext/intl/msgformat/msgformat_class.c index 36d06d2d36..d6ba9b1c67 100644 --- a/ext/intl/msgformat/msgformat_class.c +++ b/ext/intl/msgformat/msgformat_class.c @@ -83,7 +83,7 @@ zend_object_value MessageFormatter_object_clone(zval *object TSRMLS_DC) MessageFormatter_object *mfo, *new_mfo; MSG_FORMAT_METHOD_FETCH_OBJECT_NO_CHECK; - new_obj_val = MessageFormatter_ce_ptr->create_object(MessageFormatter_ce_ptr TSRMLS_CC); + new_obj_val = MessageFormatter_ce_ptr->create_object(Z_OBJCE_P(object) TSRMLS_CC); new_mfo = (MessageFormatter_object *)zend_object_store_get_object_by_handle(new_obj_val.handle TSRMLS_CC); /* clone standard parts */ zend_objects_clone_members(&new_mfo->zo, new_obj_val, &mfo->zo, handle TSRMLS_CC); -- cgit v1.2.1