/ Check-in [65b1e3a4]
Login

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

Overview
Comment:Check-in [19064d7cea] broke the pTail return on sqlite3_prepare16() when the SQL contained surrogates. This check-in restores correct function. Part of ticket [3fe897352e].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:65b1e3a4c31f6cb6fd3f600701658b0cdbee603f
User & Date: drh 2009-10-24 01:55:15
Context
2009-10-24
02:00
In shell, changed ".tables" command to not add '%' to specified pattern. This is consistent with other commands that take a LIKE pattern (.dump, .schema, .indices). Updated internal help to better describe LIKE pattern usage. Fixed a few more inconsistencies in error messages. Ticket [6da68f691b]. check-in: 7201244e user: shane tags: trunk
01:55
Check-in [19064d7cea] broke the pTail return on sqlite3_prepare16() when the SQL contained surrogates. This check-in restores correct function. Part of ticket [3fe897352e]. check-in: 65b1e3a4 user: drh tags: trunk
2009-10-23
18:15
Make sure that UTF16 to UTF8 conversions to not read past the end of the UTF16 input buffer if the last two bytes of the UTF16 happen to be the first half of a surrogate pair. Ticket [3fe897352e] check-in: 19064d7c user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/utf.c.

   484    484   ** pZ is a UTF-16 encoded unicode string at least nChar characters long.
   485    485   ** Return the number of bytes in the first nChar unicode characters
   486    486   ** in pZ.  nChar must be non-negative.
   487    487   */
   488    488   int sqlite3Utf16ByteLen(const void *zIn, int nChar){
   489    489     int c;
   490    490     unsigned char const *z = zIn;
   491         -  unsigned char const *zTerm = &z[nChar];
          491  +  unsigned char const *zTerm;
   492    492     int n = 0;
          493  +
          494  +  /* Some of the characters might be surrogates.  Be careful not to terminate
          495  +  ** the string too early because of them.   In the worst case, all characters
          496  +  ** or surrogates so make the terminator 2*nChar from the beginning. */
          497  +  zTerm = &z[nChar*2];
          498  +  
   493    499     if( SQLITE_UTF16NATIVE==SQLITE_UTF16BE ){
   494    500       /* Using an "if (SQLITE_UTF16NATIVE==SQLITE_UTF16BE)" construct here
   495    501       ** and in other parts of this file means that at one branch will
   496    502       ** not be covered by coverage testing on any single host. But coverage
   497    503       ** will be complete if the tests are run on both a little-endian and 
   498    504       ** big-endian host. Because both the UTF16NATIVE and SQLITE_UTF16BE
   499    505       ** macros are constant at compile time the compiler can determine