aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanielk1977 <danielk1977@noemail.net>2009-04-29 11:50:53 +0000
committerdanielk1977 <danielk1977@noemail.net>2009-04-29 11:50:53 +0000
commit6eacd28a289b89d024de0aac0afed06b5aae9021 (patch)
treeae302b2d950f262e7fd14fb78528949916c313de /src
parentae5558b2ae0d3e22621adf8c2b5ee9814b6ece30 (diff)
downloadsqlite-6eacd28a289b89d024de0aac0afed06b5aae9021.tar.gz
sqlite-6eacd28a289b89d024de0aac0afed06b5aae9021.zip
Fix a case in where.c where a crash can follow a malloc failure. Also modify test code in test8.c to check a return code that was being dropped (causing a test in vtab_err.test to fail). (CVS 6567)
FossilOrigin-Name: 9664e2b6c69271a7ca55af7812a186773a7c6592
Diffstat (limited to 'src')
-rw-r--r--src/test8.c4
-rw-r--r--src/where.c9
2 files changed, 9 insertions, 4 deletions
diff --git a/src/test8.c b/src/test8.c
index fa26677fe..a313c2601 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.77 2009/04/21 09:02:47 danielk1977 Exp $
+** $Id: test8.c,v 1.78 2009/04/29 11:50:54 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -695,7 +695,7 @@ static int echoFilter(
rc = sqlite3_prepare(db, idxStr, -1, &pCur->pStmt, 0);
assert( pCur->pStmt || rc!=SQLITE_OK );
for(i=0; rc==SQLITE_OK && i<argc; i++){
- sqlite3_bind_value(pCur->pStmt, i+1, argv[i]);
+ rc = sqlite3_bind_value(pCur->pStmt, i+1, argv[i]);
}
/* If everything was successful, advance to the first row of the scan */
diff --git a/src/where.c b/src/where.c
index f02689b3e..3f850d6d2 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.390 2009/04/24 15:46:22 drh Exp $
+** $Id: where.c,v 1.391 2009/04/29 11:50:54 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -1747,6 +1747,12 @@ static void bestVirtualIndex(
int i, j;
int nOrderBy;
+ /* Make sure wsFlags is initialized to some sane value. Otherwise, if the
+ ** malloc in allocateIndexInfo() fails and this function returns leaving
+ ** wsFlags in an uninitialized state, the caller may behave unpredictably.
+ */
+ pCost->plan.wsFlags = WHERE_VIRTUALTABLE;
+
/* If the sqlite3_index_info structure has not been previously
** allocated and initialized, then allocate and initialize it now.
*/
@@ -1830,7 +1836,6 @@ static void bestVirtualIndex(
}else{
pCost->rCost = pIdxInfo->estimatedCost;
}
- pCost->plan.wsFlags = WHERE_VIRTUALTABLE;
pCost->plan.u.pVtabIdx = pIdxInfo;
if( pIdxInfo && pIdxInfo->orderByConsumed ){
pCost->plan.wsFlags |= WHERE_ORDERBY;