/ Check-in [ecb1419e]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Cherry-pick the change at [2d4505510032bf9] into the 3.6.1 branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | branch-3.6.1
Files: files | file ages | folders
SHA1: ecb1419e4b359e68d583b627ac40cff33cbc06b8
User & Date: drh 2010-10-15 14:45:13
Context
2011-03-07
16:12
Backport a fix from [6b0cabd017ed25] (version 3.6.16 - 2009-03-05) to the 3.6.1 branch, a fix that prevents a null pointer deref if one of the column access routines such as sqlite3_column_int() is called with a NULL first parameter. check-in: df343640 user: drh tags: branch-3.6.1
2010-10-15
14:45
Cherry-pick the change at [2d4505510032bf9] into the 3.6.1 branch. check-in: ecb1419e user: drh tags: branch-3.6.1
2010-05-17
15:52
An improvement to the SQLITE_FCNTL_SIZE_HINT change that invokes the hint less often and only when really needed. check-in: a1d20ceb user: drh tags: branch-3.6.1
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbemem.c.

    11     11   *************************************************************************
    12     12   **
    13     13   ** This file contains code use to manipulate "Mem" structure.  A "Mem"
    14     14   ** stores a single value in the VDBE.  Mem is an opaque structure visible
    15     15   ** only within the VDBE.  Interface routines refer to a Mem using the
    16     16   ** name sqlite_value
    17     17   **
    18         -** $Id: vdbemem.c,v 1.121 2008/08/01 20:10:09 drh Exp $
           18  +** $Id: vdbemem.c,v 1.123 2008/09/16 12:06:08 danielk1977 Exp $
    19     19   */
    20     20   #include "sqliteInt.h"
    21     21   #include <ctype.h>
    22     22   #include "vdbeInt.h"
    23     23   
    24     24   /*
    25     25   ** Call sqlite3VdbeMemExpandBlob() on the supplied value (type Mem*)
................................................................................
   735    735   
   736    736       if( pColl ){
   737    737         if( pMem1->enc==pColl->enc ){
   738    738           /* The strings are already in the correct encoding.  Call the
   739    739           ** comparison function directly */
   740    740           return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z);
   741    741         }else{
   742         -        u8 origEnc = pMem1->enc;
   743    742           const void *v1, *v2;
   744    743           int n1, n2;
   745         -        /* Convert the strings into the encoding that the comparison
   746         -        ** function expects */
   747         -        v1 = sqlite3ValueText((sqlite3_value*)pMem1, pColl->enc);
   748         -        n1 = v1==0 ? 0 : pMem1->n;
   749         -        assert( n1==sqlite3ValueBytes((sqlite3_value*)pMem1, pColl->enc) );
   750         -        v2 = sqlite3ValueText((sqlite3_value*)pMem2, pColl->enc);
   751         -        n2 = v2==0 ? 0 : pMem2->n;
   752         -        assert( n2==sqlite3ValueBytes((sqlite3_value*)pMem2, pColl->enc) );
   753         -        /* Do the comparison */
          744  +        Mem c1;
          745  +        Mem c2;
          746  +        memset(&c1, 0, sizeof(c1));
          747  +        memset(&c2, 0, sizeof(c2));
          748  +        sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem);
          749  +        sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem);
          750  +        v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc);
          751  +        n1 = v1==0 ? 0 : c1.n;
          752  +        v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc);
          753  +        n2 = v2==0 ? 0 : c2.n;
   754    754           rc = pColl->xCmp(pColl->pUser, n1, v1, n2, v2);
   755         -        /* Convert the strings back into the database encoding */
   756         -        sqlite3ValueText((sqlite3_value*)pMem1, origEnc);
   757         -        sqlite3ValueText((sqlite3_value*)pMem2, origEnc);
          755  +        sqlite3VdbeMemRelease(&c1);
          756  +        sqlite3VdbeMemRelease(&c2);
   758    757           return rc;
   759    758         }
   760    759       }
   761    760       /* If a NULL pointer was passed as the collate function, fall through
   762    761       ** to the blob case and use memcmp().  */
   763    762     }
   764    763