/ Check-in [fa49666f]
Login

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

Overview
Comment:Simplifications and tweaks to vdbeaux.c resulting from structural testing. (CVS 6891)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fa49666fb913f0d82e84bdfa2af3a294be04e47c
User & Date: drh 2009-07-14 14:15:27
Context
2009-07-14
17:48
Simplifications to the PRAGMA integrity_check logic. Remove unreachable code. (CVS 6892) check-in: 17749fa5 user: drh tags: trunk
14:15
Simplifications and tweaks to vdbeaux.c resulting from structural testing. (CVS 6891) check-in: fa49666f user: drh tags: trunk
02:33
Make sure the IN operator works with zeroblobs. Ticket #3965. Other simplifications associated with structural testing. (CVS 6890) check-in: 25dd3422 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbeaux.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used for creating, destroying, and populating
    13     13   ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.)  Prior
    14     14   ** to version 2.8.7, all this code was combined into the vdbe.c source file.
    15     15   ** But that file was getting too big so this subroutines were split out.
    16     16   **
    17         -** $Id: vdbeaux.c,v 1.472 2009/07/14 02:33:02 drh Exp $
           17  +** $Id: vdbeaux.c,v 1.473 2009/07/14 14:15:27 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "vdbeInt.h"
    21     21   
    22     22   
    23     23   
    24     24   /*
................................................................................
  2420   2420     idx = getVarint32(aKey, szHdr);
  2421   2421     d = szHdr;
  2422   2422     u = 0;
  2423   2423     while( idx<szHdr && u<p->nField ){
  2424   2424       u32 serial_type;
  2425   2425   
  2426   2426       idx += getVarint32(&aKey[idx], serial_type);
  2427         -    if( d>=nKey && sqlite3VdbeSerialTypeLen(serial_type)>0 ) break;
         2427  +    assert( d+sqlite3VdbeSerialTypeLen(serial_type) <= nKey );
  2428   2428       pMem->enc = pKeyInfo->enc;
  2429   2429       pMem->db = pKeyInfo->db;
  2430   2430       pMem->flags = 0;
  2431   2431       pMem->zMalloc = 0;
  2432   2432       d += sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
  2433   2433       pMem++;
  2434   2434       u++;
................................................................................
  2529   2529       rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],
  2530   2530                              i<nField ? pKeyInfo->aColl[i] : 0);
  2531   2531       if( rc!=0 ){
  2532   2532         break;
  2533   2533       }
  2534   2534       i++;
  2535   2535     }
  2536         -  if( mem1.zMalloc ) sqlite3VdbeMemRelease(&mem1);
         2536  +
         2537  +  /* No memory allocation is ever used on mem1. */
         2538  +  if( NEVER(mem1.zMalloc) ) sqlite3VdbeMemRelease(&mem1);
  2537   2539   
  2538   2540     /* If the PREFIX_SEARCH flag is set and all fields except the final
  2539   2541     ** rowid field were equal, then clear the PREFIX_SEARCH flag and set 
  2540   2542     ** pPKey2->rowid to the value of the rowid field in (pKey1, nKey1).
  2541   2543     ** This is used by the OP_IsUnique opcode.
  2542   2544     */
  2543   2545     if( (pPKey2->flags & UNPACKED_PREFIX_SEARCH) && i==(pPKey2->nField-1) ){
................................................................................
  2664   2666   ){
  2665   2667     i64 nCellKey = 0;
  2666   2668     int rc;
  2667   2669     BtCursor *pCur = pC->pCursor;
  2668   2670     Mem m;
  2669   2671   
  2670   2672     sqlite3BtreeKeySize(pCur, &nCellKey);
  2671         -  if( nCellKey<=0 || nCellKey>0x7fffffff ){
         2673  +  /* nCellKey will always be between 0 and 0xffffffff because of the say
         2674  +  ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */
         2675  +  if( NEVER(nCellKey<=0) || nCellKey>0x7fffffff ){
  2672   2676       *res = 0;
  2673         -    return SQLITE_OK;
         2677  +    return SQLITE_CORRUPT;
  2674   2678     }
  2675   2679     m.db = 0;
  2676   2680     m.flags = 0;
  2677   2681     m.zMalloc = 0;
  2678   2682     rc = sqlite3VdbeMemFromBtree(pC->pCursor, 0, (int)nCellKey, 1, &m);
  2679   2683     if( rc ){
  2680   2684       return rc;