aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authordrh <>2021-07-09 13:52:01 +0000
committerdrh <>2021-07-09 13:52:01 +0000
commit62f560f805db23e0619740c730e737c9989e75ec (patch)
treebb813f53b58a63670e86a465cc062351f95e187d /src/main.c
parentf33e7795b3905b3dd278d5ec5c777af7a348dcd7 (diff)
downloadsqlite-62f560f805db23e0619740c730e737c9989e75ec.tar.gz
sqlite-62f560f805db23e0619740c730e737c9989e75ec.zip
Enhance the sqlite3_create_function() interfaces to assume a value of
SQLITE_UTF8 is presented with a nonsense value for the preferred encoding. This is undocumented behavior added for robustness. FossilOrigin-Name: c1bb5cff527af6a97b025d646581c68ac9b56924ae199f86964026a7bc9724fd
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/main.c b/src/main.c
index e2ebb1ef2..ca796b12c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1854,22 +1854,33 @@ int sqlite3CreateFunc(
** If SQLITE_ANY is specified, add three versions of the function
** to the hash table.
*/
- if( enc==SQLITE_UTF16 ){
- enc = SQLITE_UTF16NATIVE;
- }else if( enc==SQLITE_ANY ){
- int rc;
- rc = sqlite3CreateFunc(db, zFunctionName, nArg,
- (SQLITE_UTF8|extraFlags)^SQLITE_FUNC_UNSAFE,
- pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
- if( rc==SQLITE_OK ){
+ switch( enc ){
+ case SQLITE_UTF16:
+ enc = SQLITE_UTF16NATIVE;
+ break;
+ case SQLITE_ANY: {
+ int rc;
rc = sqlite3CreateFunc(db, zFunctionName, nArg,
- (SQLITE_UTF16LE|extraFlags)^SQLITE_FUNC_UNSAFE,
+ (SQLITE_UTF8|extraFlags)^SQLITE_FUNC_UNSAFE,
pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
+ if( rc==SQLITE_OK ){
+ rc = sqlite3CreateFunc(db, zFunctionName, nArg,
+ (SQLITE_UTF16LE|extraFlags)^SQLITE_FUNC_UNSAFE,
+ pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
+ }
+ if( rc!=SQLITE_OK ){
+ return rc;
+ }
+ enc = SQLITE_UTF16BE;
+ break;
}
- if( rc!=SQLITE_OK ){
- return rc;
- }
- enc = SQLITE_UTF16BE;
+ case SQLITE_UTF8:
+ case SQLITE_UTF16LE:
+ case SQLITE_UTF16BE:
+ break;
+ default:
+ enc = SQLITE_UTF8;
+ break;
}
#else
enc = SQLITE_UTF8;