cvs: ZendEngine2 / zend_ini.c

From: Date: Tue, 15 Jan 2008 17:10:25 +0000
Subject: cvs: ZendEngine2 / zend_ini.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-6277@lists.php.net to get a copy of this message
tony2001 Tue Jan 15 17:10:25 2008 UTC Modified files: /ZendEngine2 zend_ini.c Log: fix #43680 (OnUpdateUTF8String problems in PHP 6) patch by Christopher Jones http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_ini.c?r1=1.72&r2=1.73&diff_format=u Index: ZendEngine2/zend_ini.c diff -u ZendEngine2/zend_ini.c:1.72 ZendEngine2/zend_ini.c:1.73 --- ZendEngine2/zend_ini.c:1.72 Mon Dec 31 07:12:07 2007 +++ ZendEngine2/zend_ini.c Tue Jan 15 17:10:25 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_ini.c,v 1.72 2007/12/31 07:12:07 sebastian Exp $ */ +/* $Id: zend_ini.c,v 1.73 2008/01/15 17:10:25 tony2001 Exp $ */ #include "zend.h" #include "zend_qsort.h" @@ -640,7 +640,8 @@ 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 @@ 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; } /* }}} */

« previous php.zend-engine.cvs (#6277) next »