diff options
| author | Antony Dovgal <tony2001@php.net> | 2008-01-15 17:10:25 +0000 |
|---|---|---|
| committer | Antony Dovgal <tony2001@php.net> | 2008-01-15 17:10:25 +0000 |
| commit | 810c41e096b3869e2db67652911aa5a0f069200f (patch) | |
| tree | 3d977557b4b6e04e1caa5a80024b00752d7f92ac | |
| parent | e7c59ad6d45c7fc23e54138e2868b6b41f22bfca (diff) | |
| download | php-git-810c41e096b3869e2db67652911aa5a0f069200f.tar.gz | |
fix #43680 (OnUpdateUTF8String problems in PHP 6)
patch by Christopher Jones
| -rw-r--r-- | Zend/zend_ini.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index d5df8297c1..2e00eafc73 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -640,7 +640,8 @@ ZEND_API ZEND_INI_MH(OnUpdateStringUnempty) /* {{{ */ ZEND_API ZEND_INI_MH(OnUpdateUTF8String) /* {{{ */ { - UChar **p; + UChar **up; + char **p; UChar *ustr = NULL; int32_t ustr_len, capacity; UErrorCode status = U_ZERO_ERROR; @@ -651,30 +652,34 @@ ZEND_API ZEND_INI_MH(OnUpdateUTF8String) /* {{{ */ base = (char *) ts_resource(*((int *) mh_arg2)); #endif + /* Convert only if unicode semantics is on. Otherwise, same as OnUpdateString */ + if (UG(unicode)){ + /* estimate capacity */ + capacity = (new_value_length > 2) ? ((new_value_length >> 1) + (new_value_length >> 3) + 2) : new_value_length; + + while (1) { + ustr = peurealloc(ustr, capacity+1, 1); + u_strFromUTF8(ustr, capacity+1, &ustr_len, new_value, new_value_length, &status); + if (status == U_BUFFER_OVERFLOW_ERROR || status == U_STRING_NOT_TERMINATED_WARNING) { + capacity = ustr_len; + status = U_ZERO_ERROR; + } else { + break; + } + } - /* estimate capacity */ - capacity = (new_value_length > 2) ? ((new_value_length >> 1) + (new_value_length >> 3) + 2) : new_value_length; - - while (1) { - ustr = eurealloc(ustr, capacity+1); - u_strFromUTF8(ustr, capacity, &ustr_len, new_value, new_value_length, &status); - if (status == U_BUFFER_OVERFLOW_ERROR) { - capacity = ustr_len; - status = U_ZERO_ERROR; - } else { - break; + if (U_FAILURE(status)) { + zend_error(E_WARNING, "Could not convert UTF-8 INI value to Unicode"); + efree(ustr); + return FAILURE; } - } - if (U_FAILURE(status)) { - zend_error(E_WARNING, "Could not convert UTF-8 INI value to Unicode"); - efree(ustr); - return FAILURE; + up = (UChar **) (base+(size_t) mh_arg1); + *up = ustr; + } else { /* Same as OnUpdateString */ + p = (char **) (base+(size_t) mh_arg1); + *p = new_value; } - - p = (UChar **) (base+(size_t) mh_arg1); - - *p = ustr; return SUCCESS; } /* }}} */ |
