com php-src: Fixed encoding list building while array arg: ext/mbstring/mbstring.c
| From: | Dmitry Stogov | Date: | Mon, 24 Mar 2014 05:56:46 +0000 |
| Subject: | com php-src: Fixed encoding list building while array arg: ext/mbstring/mbstring.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-77587@lists.php.net to get a copy of this message | ||
Commit: 807ed2eb198eacb9b0d49b3557242fb12e1b0a15
Author: Xinchen Hui <laruence@gmail.com> Mon, 24 Mar 2014 13:56:27 +0800
Parents: 7caf93a785b596a0ec66b262860e37414023836a
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=807ed2eb198eacb9b0d49b3557242fb12e1b0a15
Log:
Fixed encoding list building while array arg
Changed paths:
M ext/mbstring/mbstring.c
Diff:
diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c
index 533e064..33f26dc 100644
--- a/ext/mbstring/mbstring.c
+++ b/ext/mbstring/mbstring.c
@@ -3073,44 +3073,44 @@ PHP_FUNCTION(mb_convert_encoding)
if (ZEND_NUM_ARGS() == 3) {
switch (Z_TYPE_P(arg_old)) {
- case IS_ARRAY:
- target_hash = Z_ARRVAL_P(arg_old);
- zend_hash_internal_pointer_reset(target_hash);
- i = zend_hash_num_elements(target_hash);
- _from_encodings = NULL;
+ case IS_ARRAY:
+ target_hash = Z_ARRVAL_P(arg_old);
+ zend_hash_internal_pointer_reset(target_hash);
+ i = zend_hash_num_elements(target_hash);
+ _from_encodings = NULL;
- while (i > 0) {
- if ((hash_entry = zend_hash_get_current_data(target_hash)) == NULL) {
- break;
- }
+ while (i > 0) {
+ if ((hash_entry = zend_hash_get_current_data(target_hash)) == NULL) {
+ break;
+ }
- convert_to_string_ex(hash_entry);
+ convert_to_string_ex(hash_entry);
- if ( _from_encodings) {
- l = strlen(_from_encodings);
- n = strlen(Z_STRVAL_P(hash_entry));
- _from_encodings = erealloc(_from_encodings, l+n+2);
- memcpy(_from_encodings + l, ",", 1);
- memcpy(_from_encodings + l + 1, Z_STRVAL_P(hash_entry), Z_STRLEN_P(hash_entry));
- } else {
- _from_encodings = estrdup(Z_STRVAL_P(hash_entry));
- }
+ if ( _from_encodings) {
+ l = strlen(_from_encodings);
+ n = strlen(Z_STRVAL_P(hash_entry));
+ _from_encodings = erealloc(_from_encodings, l+n+2);
+ memcpy(_from_encodings + l, ",", 1);
+ memcpy(_from_encodings + l + 1, Z_STRVAL_P(hash_entry), Z_STRLEN_P(hash_entry) + 1);
+ } else {
+ _from_encodings = estrdup(Z_STRVAL_P(hash_entry));
+ }
- zend_hash_move_forward(target_hash);
- i--;
- }
+ zend_hash_move_forward(target_hash);
+ i--;
+ }
- if (_from_encodings != NULL && !strlen(_from_encodings)) {
- efree(_from_encodings);
- _from_encodings = NULL;
+ if (_from_encodings != NULL && !strlen(_from_encodings)) {
+ efree(_from_encodings);
+ _from_encodings = NULL;
+ }
+ s_free = _from_encodings;
+ break;
+ default:
+ convert_to_string(arg_old);
+ _from_encodings = Z_STRVAL_P(arg_old);
+ break;
}
- s_free = _from_encodings;
- break;
- default:
- convert_to_string(arg_old);
- _from_encodings = Z_STRVAL_P(arg_old);
- break;
- }
}
/* new encoding */