aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/expr.c3
-rw-r--r--src/test3.c4
-rw-r--r--src/test8.c26
-rw-r--r--src/test_tclvar.c6
-rw-r--r--src/vdbeapi.c4
-rw-r--r--src/where.c4
6 files changed, 25 insertions, 22 deletions
diff --git a/src/expr.c b/src/expr.c
index 5c281fbac..d7acec840 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.305 2007/08/16 10:09:03 danielk1977 Exp $
+** $Id: expr.c,v 1.306 2007/08/16 11:36:15 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -528,6 +528,7 @@ ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p){
if( p==0 ) return 0;
pNew = sqlite3DbMallocRaw(db, sizeof(*pNew) );
if( pNew==0 ) return 0;
+ pNew->iECursor = 0;
pNew->nExpr = pNew->nAlloc = p->nExpr;
pNew->a = pItem = sqlite3DbMallocRaw(db, p->nExpr*sizeof(p->a[0]) );
if( pItem==0 ){
diff --git a/src/test3.c b/src/test3.c
index 53cdc17f2..fa174b4e1 100644
--- a/src/test3.c
+++ b/src/test3.c
@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
-** $Id: test3.c,v 1.77 2007/08/16 10:09:03 danielk1977 Exp $
+** $Id: test3.c,v 1.78 2007/08/16 11:36:15 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "pager.h"
@@ -1058,7 +1058,7 @@ static int btree_data(
rc = sqlite3BtreeData(pCur, 0, n, zBuf);
if( rc ){
Tcl_AppendResult(interp, errorName(rc), 0);
- free(zBuf);
+ sqlite3_free(zBuf);
return TCL_ERROR;
}
zBuf[n] = 0;
diff --git a/src/test8.c b/src/test8.c
index 5f3074b59..70c6c57f1 100644
--- a/src/test8.c
+++ b/src/test8.c
@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
-** $Id: test8.c,v 1.50 2007/08/16 10:09:03 danielk1977 Exp $
+** $Id: test8.c,v 1.51 2007/08/16 11:36:15 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -163,7 +163,7 @@ static int getColumnNames(
for(ii=0; ii<nCol; ii++){
nBytes += (strlen(sqlite3_column_name(pStmt, ii)) + 1);
}
- aCol = (char **)sqlite3_malloc(nBytes);
+ aCol = (char **)sqlite3MallocZero(nBytes);
if( !aCol ){
rc = SQLITE_NOMEM;
goto out;
@@ -213,7 +213,7 @@ static int getIndexArray(
char *zSql;
/* Allocate space for the index array */
- aIndex = (int *)sqlite3_malloc(sizeof(int) * nCol);
+ aIndex = (int *)sqlite3MallocZero(sizeof(int) * nCol);
if( !aIndex ){
rc = SQLITE_NOMEM;
goto get_index_array_out;
@@ -364,7 +364,7 @@ static int echoConstructor(
echo_vtab *pVtab;
/* Allocate the sqlite3_vtab/echo_vtab structure itself */
- pVtab = sqlite3_malloc( sizeof(*pVtab) );
+ pVtab = sqlite3MallocZero( sizeof(*pVtab) );
if( !pVtab ){
return SQLITE_NOMEM;
}
@@ -498,7 +498,7 @@ static int echoDestroy(sqlite3_vtab *pVtab){
*/
static int echoOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
echo_cursor *pCur;
- pCur = sqlite3_malloc(sizeof(echo_cursor));
+ pCur = sqlite3MallocZero(sizeof(echo_cursor));
*ppCursor = (sqlite3_vtab_cursor *)pCur;
return (pCur ? SQLITE_OK : SQLITE_NOMEM);
}
@@ -528,15 +528,17 @@ static int echoEof(sqlite3_vtab_cursor *cur){
** Echo virtual table module xNext method.
*/
static int echoNext(sqlite3_vtab_cursor *cur){
- int rc;
+ int rc = SQLITE_OK;
echo_cursor *pCur = (echo_cursor *)cur;
- rc = sqlite3_step(pCur->pStmt);
- if( rc==SQLITE_ROW ){
- rc = SQLITE_OK;
- }else{
- rc = sqlite3_finalize(pCur->pStmt);
- pCur->pStmt = 0;
+ if( pCur->pStmt ){
+ rc = sqlite3_step(pCur->pStmt);
+ if( rc==SQLITE_ROW ){
+ rc = SQLITE_OK;
+ }else{
+ rc = sqlite3_finalize(pCur->pStmt);
+ pCur->pStmt = 0;
+ }
}
return rc;
diff --git a/src/test_tclvar.c b/src/test_tclvar.c
index 86e762219..03e2ca64a 100644
--- a/src/test_tclvar.c
+++ b/src/test_tclvar.c
@@ -16,7 +16,7 @@
** The emphasis of this file is a virtual table that provides
** access to TCL variables.
**
-** $Id: test_tclvar.c,v 1.12 2007/08/16 04:30:40 drh Exp $
+** $Id: test_tclvar.c,v 1.13 2007/08/16 11:36:15 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -58,7 +58,7 @@ static int tclvarConnect(
tclvar_vtab *pVtab;
static const char zSchema[] =
"CREATE TABLE whatever(name TEXT, arrayname TEXT, value TEXT)";
- pVtab = sqlite3_malloc( sizeof(*pVtab) );
+ pVtab = sqlite3MallocZero( sizeof(*pVtab) );
if( pVtab==0 ) return SQLITE_NOMEM;
*ppVtab = &pVtab->base;
pVtab->interp = (Tcl_Interp *)pAux;
@@ -79,7 +79,7 @@ static int tclvarDisconnect(sqlite3_vtab *pVtab){
*/
static int tclvarOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
tclvar_cursor *pCur;
- pCur = sqlite3_malloc(sizeof(tclvar_cursor));
+ pCur = sqlite3MallocZero(sizeof(tclvar_cursor));
*ppCursor = &pCur->base;
return SQLITE_OK;
}
diff --git a/src/vdbeapi.c b/src/vdbeapi.c
index 6b80796a0..948d4b042 100644
--- a/src/vdbeapi.c
+++ b/src/vdbeapi.c
@@ -394,6 +394,7 @@ void sqlite3_set_auxdata(
pVdbeFunc = pCtx->pVdbeFunc;
if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){
+ int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0);
int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg;
pVdbeFunc = sqlite3_realloc(pVdbeFunc, nMalloc);
if( !pVdbeFunc ){
@@ -401,8 +402,7 @@ void sqlite3_set_auxdata(
goto failed;
}
pCtx->pVdbeFunc = pVdbeFunc;
- memset(&pVdbeFunc->apAux[pVdbeFunc->nAux], 0,
- sizeof(struct AuxData)*(iArg+1-pVdbeFunc->nAux));
+ memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux));
pVdbeFunc->nAux = iArg+1;
pVdbeFunc->pFunc = pCtx->pFunc;
}
diff --git a/src/where.c b/src/where.c
index d7ddc4ceb..65c7dbfe2 100644
--- a/src/where.c
+++ b/src/where.c
@@ -16,7 +16,7 @@
** so is applicable. Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
-** $Id: where.c,v 1.256 2007/08/16 10:09:03 danielk1977 Exp $
+** $Id: where.c,v 1.257 2007/08/16 11:36:15 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -1260,7 +1260,7 @@ static double bestVirtualIndex(
/* Allocate the sqlite3_index_info structure
*/
- pIdxInfo = sqlite3_malloc( sizeof(*pIdxInfo)
+ pIdxInfo = sqlite3MallocZero( sizeof(*pIdxInfo)
+ (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm
+ sizeof(*pIdxOrderBy)*nOrderBy );
if( pIdxInfo==0 ){