aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/btree.c9
-rw-r--r--src/build.c4
-rw-r--r--src/expr.c10
-rw-r--r--src/insert.c4
-rw-r--r--src/legacy.c4
-rw-r--r--src/pager.c8
-rw-r--r--src/prepare.c3
-rw-r--r--src/printf.c4
-rw-r--r--src/select.c5
-rw-r--r--src/shell.c13
-rw-r--r--src/tclsqlite.c3
-rw-r--r--src/trigger.c9
12 files changed, 46 insertions, 30 deletions
diff --git a/src/btree.c b/src/btree.c
index eb481bd0f..f3f233686 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.316 2006/02/24 02:53:50 drh Exp $
+** $Id: btree.c,v 1.317 2006/03/06 20:55:46 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@@ -867,7 +867,8 @@ static int ptrmapGet(BtShared *pBt, Pgno key, u8 *pEType, Pgno *pPgno){
}
offset = PTRMAP_PTROFFSET(pBt, key);
- if( pEType ) *pEType = pPtrmap[offset];
+ assert( pEType!=0 );
+ *pEType = pPtrmap[offset];
if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]);
sqlite3pager_unref(pPtrmap);
@@ -2463,7 +2464,6 @@ static int autoVacuumCommit(BtShared *pBt, Pgno *nTrunc){
if( rc!=SQLITE_OK ) goto autovacuum_out;
put4byte(&pBt->pPage1->aData[32], 0);
put4byte(&pBt->pPage1->aData[36], 0);
- if( rc!=SQLITE_OK ) goto autovacuum_out;
*nTrunc = finSize;
assert( finSize!=PENDING_BYTE_PAGE(pBt) );
@@ -4093,6 +4093,7 @@ static int reparentPage(BtShared *pBt, Pgno pgno, MemPage *pNewParent, int idx){
MemPage *pThis;
unsigned char *aData;
+ assert( pNewParent!=0 );
if( pgno==0 ) return SQLITE_OK;
assert( pBt->pPager!=0 );
aData = sqlite3pager_lookup(pBt->pPager, pgno);
@@ -4103,7 +4104,7 @@ static int reparentPage(BtShared *pBt, Pgno pgno, MemPage *pNewParent, int idx){
if( pThis->pParent!=pNewParent ){
if( pThis->pParent ) sqlite3pager_unref(pThis->pParent->aData);
pThis->pParent = pNewParent;
- if( pNewParent ) sqlite3pager_ref(pNewParent->aData);
+ sqlite3pager_ref(pNewParent->aData);
}
pThis->idxParent = idx;
}
diff --git a/src/build.c b/src/build.c
index 2e1eb6a05..23d36de60 100644
--- a/src/build.c
+++ b/src/build.c
@@ -22,7 +22,7 @@
** COMMIT
** ROLLBACK
**
-** $Id: build.c,v 1.389 2006/02/24 02:53:50 drh Exp $
+** $Id: build.c,v 1.390 2006/03/06 20:55:46 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -3108,7 +3108,7 @@ static void reindexDatabases(Parse *pParse, char const *zColl){
Table *pTab; /* A table in the database */
for(iDb=0, pDb=db->aDb; iDb<db->nDb; iDb++, pDb++){
- if( pDb==0 ) continue;
+ assert( pDb!=0 );
for(k=sqliteHashFirst(&pDb->pSchema->tblHash); k; k=sqliteHashNext(k)){
pTab = (Table*)sqliteHashData(k);
reindexTable(pParse, pTab, zColl);
diff --git a/src/expr.c b/src/expr.c
index 0edad9974..857294739 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
-** $Id: expr.c,v 1.255 2006/03/02 04:44:24 drh Exp $
+** $Id: expr.c,v 1.256 2006/03/06 20:55:46 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -841,11 +841,13 @@ static int lookupName(
if( pSrcList ){
for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){
- Table *pTab = pItem->pTab;
- int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
+ Table *pTab;
+ int iDb;
Column *pCol;
- if( pTab==0 ) continue;
+ pTab = pItem->pTab;
+ assert( pTab!=0 );
+ iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
assert( pTab->nCol>0 );
if( zTab ){
if( pItem->zAlias ){
diff --git a/src/insert.c b/src/insert.c
index 21b600c9b..7e4048228 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle INSERT statements in SQLite.
**
-** $Id: insert.c,v 1.162 2006/02/24 02:53:50 drh Exp $
+** $Id: insert.c,v 1.163 2006/03/06 20:55:46 drh Exp $
*/
#include "sqliteInt.h"
@@ -269,7 +269,7 @@ void sqlite3Insert(
if( sqlite3IsReadOnly(pParse, pTab, triggers_exist) ){
goto insert_cleanup;
}
- if( pTab==0 ) goto insert_cleanup;
+ assert( pTab!=0 );
/* If pTab is really a view, make sure it has been initialized.
*/
diff --git a/src/legacy.c b/src/legacy.c
index 12749c1de..d724e8a42 100644
--- a/src/legacy.c
+++ b/src/legacy.c
@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
-** $Id: legacy.c,v 1.13 2006/01/23 13:14:55 drh Exp $
+** $Id: legacy.c,v 1.14 2006/03/06 20:55:46 drh Exp $
*/
#include "sqliteInt.h"
@@ -54,8 +54,8 @@ int sqlite3_exec(
pStmt = 0;
rc = sqlite3_prepare(db, zSql, -1, &pStmt, &zLeftover);
+ assert( rc==SQLITE_OK || pStmt==0 );
if( rc!=SQLITE_OK ){
- if( pStmt ) sqlite3_finalize(pStmt);
continue;
}
if( !pStmt ){
diff --git a/src/pager.c b/src/pager.c
index 66bd44869..865dc9509 100644
--- a/src/pager.c
+++ b/src/pager.c
@@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.261 2006/03/06 18:23:17 drh Exp $
+** @(#) $Id: pager.c,v 1.262 2006/03/06 20:55:46 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
@@ -1302,9 +1302,6 @@ static int pager_playback(Pager *pPager){
pPager->dbSize = mxPg;
}
- /* rc = sqlite3OsSeek(pPager->jfd, JOURNAL_HDR_SZ(pPager)); */
- if( rc!=SQLITE_OK ) goto end_playback;
-
/* Copy original pages out of the journal and back into the database file.
*/
for(i=0; i<nRec; i++){
@@ -3153,8 +3150,9 @@ void sqlite3pager_dont_write(Pager *pPager, Pgno pgno){
if( MEMDB ) return;
pPg = pager_lookup(pPager, pgno);
+ assert( pPg!=0 ); /* We never call _dont_write unless the page is in mem */
pPg->alwaysRollback = 1;
- if( pPg && pPg->dirty && !pPager->stmtInUse ){
+ if( pPg->dirty && !pPager->stmtInUse ){
if( pPager->dbSize==(int)pPg->pgno && pPager->origDbSize<pPager->dbSize ){
/* If this pages is the last page in the file and the file has grown
** during the current transaction, then do NOT mark the page as clean.
diff --git a/src/prepare.c b/src/prepare.c
index c755d6b93..c345614eb 100644
--- a/src/prepare.c
+++ b/src/prepare.c
@@ -13,7 +13,7 @@
** interface, and routines that contribute to loading the database schema
** from disk.
**
-** $Id: prepare.c,v 1.31 2006/02/10 02:27:43 danielk1977 Exp $
+** $Id: prepare.c,v 1.32 2006/03/06 20:55:46 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -74,6 +74,7 @@ int sqlite3InitCallback(void *pInit, int argc, char **argv, char **azColName){
db->init.newTnum = atoi(argv[1]);
rc = sqlite3_exec(db, argv[2], 0, 0, &zErr);
db->init.iDb = 0;
+ assert( rc!=SQLITE_OK || zErr==0 );
if( SQLITE_OK!=rc ){
if( rc==SQLITE_NOMEM ){
sqlite3FailedMalloc();
diff --git a/src/printf.c b/src/printf.c
index e4396144b..7c4b6b007 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -340,6 +340,10 @@ static int vxprintf(
}
}
zExtra = 0;
+ if( infop==0 ){
+ return -1;
+ }
+
/* Limit the precision to prevent overflowing buf[] during conversion */
if( precision>etBUFSIZE-40 && (infop->flags & FLAG_STRING)==0 ){
diff --git a/src/select.c b/src/select.c
index cf9a9f5cf..bb6029173 100644
--- a/src/select.c
+++ b/src/select.c
@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
-** $Id: select.c,v 1.305 2006/02/24 02:53:50 drh Exp $
+** $Id: select.c,v 1.306 2006/03/06 20:55:46 drh Exp $
*/
#include "sqliteInt.h"
@@ -2687,7 +2687,8 @@ static void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){
CollSeq *pColl = 0;
struct ExprList_item *pItem;
int j;
- for(j=0, pItem=pList->a; !pColl && j<pList->nExpr; j++, pItem++){
+ assert( pList!=0 ); /* pList!=0 if pF->pFunc->needCollSeq is true */
+ for(j=0, pItem=pList->a; !pColl && j<nArg; j++, pItem++){
pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr);
}
if( !pColl ){
diff --git a/src/shell.c b/src/shell.c
index 09832d036..a8fdb7144 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -12,7 +12,7 @@
** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases.
**
-** $Id: shell.c,v 1.133 2006/01/31 19:31:44 drh Exp $
+** $Id: shell.c,v 1.134 2006/03/06 20:55:46 drh Exp $
*/
#include <stdlib.h>
#include <string.h>
@@ -62,7 +62,7 @@ static sqlite3 *db = 0;
/*
** True if an interrupt (Control-C) has been received.
*/
-static int seenInterrupt = 0;
+static volatile int seenInterrupt = 0;
/*
** This is the name of our program. It is set in main(), used
@@ -1074,7 +1074,10 @@ static int do_meta_command(char *zLine, struct callback_data *p){
return 0;
}
azCol = malloc( sizeof(azCol[0])*(nCol+1) );
- if( azCol==0 ) return 0;
+ if( azCol==0 ){
+ fclose(in);
+ return 0;
+ }
sqlite3_exec(p->db, "BEGIN", 0, 0, 0);
zCommit = "COMMIT";
while( (zLine = local_getline(0, in))!=0 ){
@@ -1371,6 +1374,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
if( c=='w' && strncmp(azArg[0], "width", n)==0 ){
int j;
+ assert( nArg<=ArraySize(azArg) );
for(j=1; j<nArg && j<ArraySize(p->colWidth); j++){
p->colWidth[j-1] = atoi(azArg[j]);
}
@@ -1560,7 +1564,7 @@ static void process_sqliterc(
){
char *home_dir = NULL;
const char *sqliterc = sqliterc_override;
- char *zBuf;
+ char *zBuf = 0;
FILE *in = NULL;
if (sqliterc == NULL) {
@@ -1586,6 +1590,7 @@ static void process_sqliterc(
process_input(p,in);
fclose(in);
}
+ free(zBuf);
return;
}
diff --git a/src/tclsqlite.c b/src/tclsqlite.c
index ed6123be1..8f3a0b68a 100644
--- a/src/tclsqlite.c
+++ b/src/tclsqlite.c
@@ -11,7 +11,7 @@
*************************************************************************
** A TCL Interface to SQLite
**
-** $Id: tclsqlite.c,v 1.152 2006/03/03 20:32:19 drh Exp $
+** $Id: tclsqlite.c,v 1.153 2006/03/06 20:55:46 drh Exp $
*/
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
@@ -1085,6 +1085,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
azCol = malloc( sizeof(azCol[0])*(nCol+1) );
if( azCol==0 ) {
Tcl_AppendResult(interp, "Error: can't malloc()", 0);
+ fclose(in);
return TCL_ERROR;
}
sqlite3_exec(pDb->db, "BEGIN", 0, 0, 0);
diff --git a/src/trigger.c b/src/trigger.c
index 9408d1b18..91b6defe7 100644
--- a/src/trigger.c
+++ b/src/trigger.c
@@ -60,9 +60,11 @@ void sqlite3BeginTrigger(
DbFixer sFix;
int iTabDb;
+ assert( pName1!=0 ); /* pName1->z might be NULL, but not pName1 itself */
+ assert( pName2!=0 );
if( isTemp ){
/* If TEMP was specified, then the trigger name may not be qualified. */
- if( pName2 && pName2->n>0 ){
+ if( pName2->n>0 ){
sqlite3ErrorMsg(pParse, "temporary trigger may not have qualified name");
goto trigger_cleanup;
}
@@ -488,7 +490,7 @@ void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){
iDb = sqlite3SchemaToIndex(pParse->db, pTrigger->pSchema);
assert( iDb>=0 && iDb<db->nDb );
pTable = tableOfTrigger(pTrigger);
- assert(pTable);
+ assert( pTable );
assert( pTable->pSchema==pTrigger->pSchema || iDb==1 );
#ifndef SQLITE_OMIT_AUTHORIZATION
{
@@ -505,7 +507,8 @@ void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){
/* Generate code to destroy the database record of the trigger.
*/
- if( pTable!=0 && (v = sqlite3GetVdbe(pParse))!=0 ){
+ assert( pTable!=0 );
+ if( (v = sqlite3GetVdbe(pParse))!=0 ){
int base;
static const VdbeOpList dropTrigger[] = {
{ OP_Rewind, 0, ADDR(9), 0},