| Index: third_party/sqlite/amalgamation/sqlite3.c
|
| diff --git a/third_party/sqlite/amalgamation/sqlite3.c b/third_party/sqlite/amalgamation/sqlite3.c
|
| index 0e12bc1d57a5f2657c7195cdce1380f427e138a7..7ff9e8d2ae5cacb7431f1f4e58077c2edec4a389 100644
|
| --- a/third_party/sqlite/amalgamation/sqlite3.c
|
| +++ b/third_party/sqlite/amalgamation/sqlite3.c
|
| @@ -161752,11 +161752,11 @@ static void icuRegexpFunc(sqlite3_context *p, int nArg, sqlite3_value **apArg){
|
| */
|
| static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){
|
| const UChar *zInput;
|
| - UChar *zOutput;
|
| + UChar *zOutput = 0;
|
| int nInput;
|
| - int nOutput;
|
| -
|
| - UErrorCode status = U_ZERO_ERROR;
|
| + int nOut;
|
| + int cnt;
|
| + UErrorCode status;
|
| const char *zLocale = 0;
|
|
|
| assert(nArg==1 || nArg==2);
|
| @@ -161768,45 +161768,34 @@ static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){
|
| if( !zInput ){
|
| return;
|
| }
|
| - nOutput = nInput = sqlite3_value_bytes16(apArg[0]);
|
| -
|
| - zOutput = sqlite3_malloc(nOutput);
|
| - if( !zOutput ){
|
| + nOut = nInput = sqlite3_value_bytes16(apArg[0]);
|
| + if( nOut==0 ){
|
| + sqlite3_result_text16(p, "", 0, SQLITE_STATIC);
|
| return;
|
| }
|
|
|
| - if( sqlite3_user_data(p) ){
|
| - nOutput = u_strToUpper(
|
| - zOutput, nOutput/2, zInput, nInput/2, zLocale, &status) * 2;
|
| - }else{
|
| - nOutput = u_strToLower(
|
| - zOutput, nOutput/2, zInput, nInput/2, zLocale, &status) * 2;
|
| - }
|
| -
|
| - if ( status == U_BUFFER_OVERFLOW_ERROR ) {
|
| - UChar* newOutput = sqlite3_realloc(zOutput, nOutput);
|
| - if( !newOutput ){
|
| + for(cnt=0; cnt<2; cnt++){
|
| + UChar *zNew = sqlite3_realloc(zOutput, nOut);
|
| + if( zNew==0 ){
|
| sqlite3_free(zOutput);
|
| + sqlite3_result_error_nomem(p);
|
| return;
|
| }
|
| - zOutput = newOutput;
|
| + zOutput = zNew;
|
| status = U_ZERO_ERROR;
|
| if( sqlite3_user_data(p) ){
|
| - nOutput = u_strToUpper(
|
| - zOutput, nOutput/2, zInput, nInput/2, zLocale, &status) * 2;
|
| + nOut = 2*u_strToUpper(zOutput,nOut/2,zInput,nInput/2,zLocale,&status);
|
| }else{
|
| - nOutput = u_strToLower(
|
| - zOutput, nOutput/2, zInput, nInput/2, zLocale, &status) * 2;
|
| + nOut = 2*u_strToLower(zOutput,nOut/2,zInput,nInput/2,zLocale,&status);
|
| + }
|
| + if( !U_SUCCESS(status) ){
|
| + if( status==U_BUFFER_OVERFLOW_ERROR ) continue;
|
| + icuFunctionError(p,
|
| + sqlite3_user_data(p) ? "u_strToUpper()" : "u_strToLower", status);
|
| + return;
|
| }
|
| }
|
| -
|
| - if( U_FAILURE(status) ){
|
| - icuFunctionError(p, "u_strToLower()/u_strToUpper", status);
|
| - sqlite3_free(zOutput);
|
| - return;
|
| - }
|
| -
|
| - sqlite3_result_text16(p, zOutput, nOutput, xFree);
|
| + sqlite3_result_text16(p, zOutput, nOut, xFree);
|
| }
|
|
|
| /*
|
|
|