1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-21 11:13:54 +03:00

Fix a bug in concat_ws() in which an initial empty string was treated as if

it was a NULL value.

FossilOrigin-Name: eb2e4e46171c12f59aa5d571eeb310534360b110c3e7bda6eaf68f0e25546264
This commit is contained in:
drh
2025-10-13 12:36:54 +00:00
parent c93270ebc7
commit a8bb50ce95
4 changed files with 20 additions and 9 deletions

View File

@@ -1669,6 +1669,7 @@ static void concatFuncCore(
){
i64 j, n = 0;
int i;
int bNotNull = 0; /* True after at least NOT NULL argument seen */
char *z;
for(i=0; i<argc; i++){
n += sqlite3_value_bytes(argv[i]);
@@ -1685,12 +1686,13 @@ static void concatFuncCore(
int k = sqlite3_value_bytes(argv[i]);
const char *v = (const char*)sqlite3_value_text(argv[i]);
if( v!=0 ){
if( j>0 && nSep>0 ){
if( bNotNull && nSep>0 ){
memcpy(&z[j], zSep, nSep);
j += nSep;
}
memcpy(&z[j], v, k);
j += k;
bNotNull = 1;
}
}
}