Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: third_party/sqlite/amalgamation/sqlite3.c

Side-by-side diff isn't available for this file because of its large size.
Issue 1746453002: [sqlite] Backport icuCaseFunc16 patch from SQLite. Base URL: https://chromium.googlesource.com/chromium/src.git@zzsql_patch_backport_icu_compare
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
« no previous file with comments | « no previous file | third_party/sqlite/patches/0013-backport-Fix-buffer-overrun-in-ICU-extension-s-casem.patch » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
/*
« no previous file with comments | « no previous file | third_party/sqlite/patches/0013-backport-Fix-buffer-overrun-in-ICU-extension-s-casem.patch » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698