/ Check-in [1c8ec2a6]
Login

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

Overview
Comment:Make sure the sqlite3VdbeGetOp() subroutine works even when SQLite is compiled with SQLITE_OMIT_TRACE. (CVS 6784)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:1c8ec2a6e4efbb3fdc58f999b7b725fa5dc4d0e9
User & Date: drh 2009-06-19 00:33:32
Context
2009-06-19
02:25
Fix a possible segfault when backing up an encrypted database. (CVS 6785) check-in: 7d8f178c user: drh tags: trunk
00:33
Make sure the sqlite3VdbeGetOp() subroutine works even when SQLite is compiled with SQLITE_OMIT_TRACE. (CVS 6784) check-in: 1c8ec2a6 user: drh tags: trunk
2009-06-18
20:52
Changes to the backup functionality so that it works better with codecs. (CVS 6783) check-in: 87d6796d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

    14     14   ** The pager is used to access a database disk file.  It implements
    15     15   ** atomic commit and rollback through the use of a journal file that
    16     16   ** is separate from the database file.  The pager also implements file
    17     17   ** locking to prevent two processes from writing the same database
    18     18   ** file simultaneously, or one process from reading the database while
    19     19   ** another is writing.
    20     20   **
    21         -** @(#) $Id: pager.c,v 1.595 2009/06/18 20:52:47 drh Exp $
           21  +** @(#) $Id: pager.c,v 1.596 2009/06/19 00:33:32 drh Exp $
    22     22   */
    23     23   #ifndef SQLITE_OMIT_DISKIO
    24     24   #include "sqliteInt.h"
    25     25   
    26     26   /*
    27     27   ** Macros for troubleshooting.  Normally turned off
    28     28   */

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.460 2009/06/09 18:58:53 shane Exp $
           17  +** $Id: vdbeaux.c,v 1.461 2009/06/19 00:33:32 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "vdbeInt.h"
    21     21   
    22     22   
    23     23   
    24     24   /*
................................................................................
   622    622   ** return the most recently inserted opcode.
   623    623   **
   624    624   ** If a memory allocation error has occurred prior to the calling of this
   625    625   ** routine, then a pointer to a dummy VdbeOp will be returned.  That opcode
   626    626   ** is readable and writable, but it has no effect.  The return of a dummy
   627    627   ** opcode allows the call to continue functioning after a OOM fault without
   628    628   ** having to check to see if the return from this routine is a valid pointer.
          629  +**
          630  +** About the #ifdef SQLITE_OMIT_TRACE:  Normally, this routine is never called
          631  +** unless p->nOp>0.  This is because in the absense of SQLITE_OMIT_TRACE,
          632  +** an OP_Trace instruction is always inserted by sqlite3VdbeGet() as soon as
          633  +** a new VDBE is created.  So we are free to set addr to p->nOp-1 without
          634  +** having to double-check to make sure that the result is non-negative. But
          635  +** if SQLITE_OMIT_TRACE is defined, the OP_Trace is omitted and we do need to
          636  +** check the value of p->nOp-1 before continuing.
   629    637   */
   630    638   VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){
   631    639     static VdbeOp dummy;
   632    640     assert( p->magic==VDBE_MAGIC_INIT );
   633         -  if( addr<0 ) addr = p->nOp - 1;
          641  +  if( addr<0 ){
          642  +#ifdef SQLITE_OMIT_TRACE
          643  +    if( p->nOp==0 ) return &dummy;
          644  +#endif
          645  +    addr = p->nOp - 1;
          646  +  }
   634    647     assert( (addr>=0 && addr<p->nOp) || p->db->mallocFailed );
   635    648     if( p->db->mallocFailed ){
   636    649       return &dummy;
   637    650     }else{
   638    651       return &p->aOp[addr];
   639    652     }
   640    653   }