com php-src: Fixed temporarily un-expected object re-init: ext/intl/breakiterator/breakiterator_class.cpp ext/intl/b
reakiterator/breakiterator_class.h ext/intl/breakiterator /breakiterator_methods.cpp ext/intl/breakiterator/rulebas edbreakiterator_methods.cpp
| From: | Xinchen Hui | Date: | Sun, 29 Jun 2014 07:28:55 +0000 |
| Subject: | com php-src: Fixed temporarily un-expected object re-init: ext/intl/breakiterator/breakiterator_class.cpp ext/intl/b reakiterator/breakiterator_class.h ext/intl/breakiterator /breakiterator_methods.cpp ext/intl/breakiterator/rulebas edbreakiterator_methods.cpp |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-79114@lists.php.net to get a copy of this message | ||
Commit: 9fb8c16b6cd5f8c47ab6b83b821f0bf79448bcac
Author: Xinchen Hui <laruence@php.net> Sun, 29 Jun 2014 15:24:00 +0800
Parents: e1437022e188747495badcfa2b86282456bc27e8
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9fb8c16b6cd5f8c47ab6b83b821f0bf79448bcac
Log:
Fixed temporarily un-expected object re-init
Changed paths:
M ext/intl/breakiterator/breakiterator_class.cpp
M ext/intl/breakiterator/breakiterator_class.h
M ext/intl/breakiterator/breakiterator_methods.cpp
M ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
Diff:
diff --git a/ext/intl/breakiterator/breakiterator_class.cpp
b/ext/intl/breakiterator/breakiterator_class.cpp
index ecaf503..7aa1eae 100644
--- a/ext/intl/breakiterator/breakiterator_class.cpp
+++ b/ext/intl/breakiterator/breakiterator_class.cpp
@@ -47,7 +47,7 @@ zend_object_handlers BreakIterator_handlers;
/* }}} */
U_CFUNC void breakiterator_object_create(zval *object,
- BreakIterator *biter TSRMLS_DC)
+ BreakIterator *biter, int brand_new TSRMLS_DC)
{
UClassID classId = biter->getDynamicClassID();
zend_class_entry *ce;
@@ -60,7 +60,9 @@ U_CFUNC void breakiterator_object_create(zval *object,
ce = BreakIterator_ce_ptr;
}
- object_init_ex(object, ce);
+ if (brand_new) {
+ object_init_ex(object, ce);
+ }
breakiterator_object_construct(object, biter TSRMLS_CC);
}
diff --git a/ext/intl/breakiterator/breakiterator_class.h
b/ext/intl/breakiterator/breakiterator_class.h
index 81074c2..0cf213f 100644
--- a/ext/intl/breakiterator/breakiterator_class.h
+++ b/ext/intl/breakiterator/breakiterator_class.h
@@ -62,7 +62,7 @@ static inline BreakIterator_object *php_intl_breakiterator_fetch_object(zend_obj
RETURN_FALSE; \
}
-void breakiterator_object_create(zval *object, BreakIterator *break_iter TSRMLS_DC);
+void breakiterator_object_create(zval *object, BreakIterator *break_iter, int brand_new TSRMLS_DC);
void breakiterator_object_construct(zval *object, BreakIterator *break_iter TSRMLS_DC);
diff --git a/ext/intl/breakiterator/breakiterator_methods.cpp
b/ext/intl/breakiterator/breakiterator_methods.cpp
index 712c58f..ed5944a 100644
--- a/ext/intl/breakiterator/breakiterator_methods.cpp
+++ b/ext/intl/breakiterator/breakiterator_methods.cpp
@@ -73,7 +73,7 @@ static void _breakiter_factory(const char *func_name,
RETURN_NULL();
}
- breakiterator_object_create(return_value, biter TSRMLS_CC);
+ breakiterator_object_create(return_value, biter, 1 TSRMLS_CC);
}
U_CFUNC PHP_FUNCTION(breakiter_create_word_instance)
@@ -123,7 +123,7 @@ U_CFUNC PHP_FUNCTION(breakiter_create_code_point_instance)
}
CodePointBreakIterator *cpbi = new CodePointBreakIterator();
- breakiterator_object_create(return_value, cpbi TSRMLS_CC);
+ breakiterator_object_create(return_value, cpbi, 1 TSRMLS_CC);
}
U_CFUNC PHP_FUNCTION(breakiter_get_text)
diff --git a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
index 0871f44..36a3a8d 100644
--- a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
+++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp
@@ -42,7 +42,8 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
&rules, &rules_len, &compiled) == FAILURE) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
"rbbi_create_instance: bad arguments", 0 TSRMLS_CC);
- RETURN_NULL();
+ Z_OBJ_P(return_value) == NULL;
+ return;
}
// instantiation of ICU object
@@ -71,7 +72,8 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
intl_error_set_custom_msg(NULL, msg, 1 TSRMLS_CC);
efree(msg);
delete rbbi;
- RETURN_NULL();
+ Z_OBJ_P(return_value) == NULL;
+ return;
}
} else { // compiled
#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM >= 48
@@ -79,17 +81,18 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS)
if (U_FAILURE(status)) {
intl_error_set(NULL, status, "rbbi_create_instance: unable to "
"create instance from compiled rules", 0 TSRMLS_CC);
- delete rbbi;
- RETURN_NULL();
+ Z_OBJ_P(return_value) == NULL;
+ return;
}
#else
intl_error_set(NULL, U_UNSUPPORTED_ERROR, "rbbi_create_instance: "
"compiled rules require ICU >= 4.8", 0 TSRMLS_CC);
- RETURN_NULL();
+ Z_OBJ_P(return_value) == NULL;
+ return;
#endif
}
- breakiterator_object_create(return_value, rbbi TSRMLS_CC);
+ breakiterator_object_create(return_value, rbbi, 0 TSRMLS_CC);
}
U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, __construct)
@@ -97,10 +100,9 @@ U_CFUNC PHP_METHOD(IntlRuleBasedBreakIterator, __construct)
zval orig_this = *getThis();
return_value = getThis();
- //changes this to IS_NULL (without first destroying) if there's an error
_php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAM_PASSTHRU);
- if (Z_TYPE_P(return_value) == IS_NULL) {
+ if (Z_TYPE_P(return_value) == IS_OBJECT && Z_OBJ_P(return_value) == NULL) {
zend_object_store_ctor_failed(Z_OBJ(orig_this) TSRMLS_CC);
zval_dtor(&orig_this);
}