mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
For the sqlite3_bind and sqlite3_result interfaces for UTF16 strings, round
the number of bytes down to the next even number, to avoid creating a UTF16 string that is an odd number of bytes. [forum:/forumpost/411199488d065f83|Forum post 411199488d065f83]. FossilOrigin-Name: b57e3c3db00a6bc6db20c82530479f9eba7e37b731f0da6fe81682e84c7ac916
This commit is contained in:
@@ -505,7 +505,10 @@ void sqlite3_result_text64(
|
||||
){
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
assert( xDel!=SQLITE_DYNAMIC );
|
||||
if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
|
||||
if( enc!=SQLITE_UTF8 ){
|
||||
if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
|
||||
n &= ~(u64)1;
|
||||
}
|
||||
if( n>0x7fffffff ){
|
||||
(void)invokeValueDestructor(z, xDel, pCtx);
|
||||
}else{
|
||||
@@ -520,7 +523,7 @@ void sqlite3_result_text16(
|
||||
void (*xDel)(void *)
|
||||
){
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel);
|
||||
setResultStrOrError(pCtx, z, n & ~(u64)1, SQLITE_UTF16NATIVE, xDel);
|
||||
}
|
||||
void sqlite3_result_text16be(
|
||||
sqlite3_context *pCtx,
|
||||
@@ -529,7 +532,7 @@ void sqlite3_result_text16be(
|
||||
void (*xDel)(void *)
|
||||
){
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
setResultStrOrError(pCtx, z, n, SQLITE_UTF16BE, xDel);
|
||||
setResultStrOrError(pCtx, z, n & ~(u64)1, SQLITE_UTF16BE, xDel);
|
||||
}
|
||||
void sqlite3_result_text16le(
|
||||
sqlite3_context *pCtx,
|
||||
@@ -538,7 +541,7 @@ void sqlite3_result_text16le(
|
||||
void (*xDel)(void *)
|
||||
){
|
||||
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
|
||||
setResultStrOrError(pCtx, z, n, SQLITE_UTF16LE, xDel);
|
||||
setResultStrOrError(pCtx, z, n & ~(u64)1, SQLITE_UTF16LE, xDel);
|
||||
}
|
||||
#endif /* SQLITE_OMIT_UTF16 */
|
||||
void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){
|
||||
@@ -1603,7 +1606,10 @@ int sqlite3_bind_text64(
|
||||
unsigned char enc
|
||||
){
|
||||
assert( xDel!=SQLITE_DYNAMIC );
|
||||
if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
|
||||
if( enc!=SQLITE_UTF8 ){
|
||||
if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
|
||||
nData &= ~(u16)1;
|
||||
}
|
||||
return bindText(pStmt, i, zData, nData, xDel, enc);
|
||||
}
|
||||
#ifndef SQLITE_OMIT_UTF16
|
||||
@@ -1611,10 +1617,10 @@ int sqlite3_bind_text16(
|
||||
sqlite3_stmt *pStmt,
|
||||
int i,
|
||||
const void *zData,
|
||||
int nData,
|
||||
int n,
|
||||
void (*xDel)(void*)
|
||||
){
|
||||
return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);
|
||||
return bindText(pStmt, i, zData, n & ~(u64)1, xDel, SQLITE_UTF16NATIVE);
|
||||
}
|
||||
#endif /* SQLITE_OMIT_UTF16 */
|
||||
int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
|
||||
|
Reference in New Issue
Block a user