SQLite

Check-in [1c0a05b0]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix another case where malformed utf-8 was being mishandled in fts5. Fix for [df46a6f3].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1c0a05b09a97e6e2e9b11c31ed6ec7e6484686614b587ebfd0cfe27d973ba461
User & Date: dan 2019-12-24 16:20:05
Context
2019-12-24
18:53
Make the zipfile() extension function more robust against zero-length filenames. (check-in: b9c2005f user: drh tags: trunk)
16:20
Fix another case where malformed utf-8 was being mishandled in fts5. Fix for [df46a6f3]. (check-in: 1c0a05b0 user: dan tags: trunk)
15:35
Fix an assert() added as part of commit [a11b393dc] that can fail if fts5 database records are corrupt. (check-in: 4630c1ec user: dan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/fts5/fts5_index.c.

5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324



5325
5326
5327
5328
5329
5330
5331
  int nChar
){
  int n = 0;
  int i;
  for(i=0; i<nChar; i++){
    if( n>=nByte ) return 0;      /* Input contains fewer than nChar chars */
    if( (unsigned char)p[n++]>=0xc0 ){
      if( n>=nByte ) break;
      while( (p[n] & 0xc0)==0x80 ){
        n++;
        if( n>=nByte ) break;



      }
    }
  }
  return n;
}

/*







|


|
>
>
>







5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
  int nChar
){
  int n = 0;
  int i;
  for(i=0; i<nChar; i++){
    if( n>=nByte ) return 0;      /* Input contains fewer than nChar chars */
    if( (unsigned char)p[n++]>=0xc0 ){
      if( n>=nByte ) return 0;
      while( (p[n] & 0xc0)==0x80 ){
        n++;
        if( n>=nByte ){
          if( i+1==nChar ) break;
          return 0;
        }
      }
    }
  }
  return n;
}

/*

Changes to ext/fts5/test/fts5misc.test.

261
262
263
264
265
266
267

















268
269
270
do_execsql_test 10.1 {
  SELECT quote(CAST(c1 AS blob)), quote(CAST(c2 AS blob)) FROM vt1
} {X'E4' X'E494AC'}

do_execsql_test 10.2 {
  INSERT INTO vt1(vt1) VALUES('integrity-check');
}


















finish_test








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
do_execsql_test 10.1 {
  SELECT quote(CAST(c1 AS blob)), quote(CAST(c2 AS blob)) FROM vt1
} {X'E4' X'E494AC'}

do_execsql_test 10.2 {
  INSERT INTO vt1(vt1) VALUES('integrity-check');
}

#-------------------------------------------------------------------------
#
reset_db
do_execsql_test 11.0 {
  CREATE VIRTUAL TABLE vt0 USING fts5(
      c0, prefix = 71, tokenize = "porter ascii", prefix = 9
  );
} {}

do_execsql_test 11.1 {
  BEGIN;
  INSERT INTO vt0(c0) VALUES (x'e8');
}
do_execsql_test 11.2 {
  INSERT INTO vt0(vt0) VALUES('integrity-check');
}

finish_test