1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

Prevent memory leak and possible NULL pointer deference after malloc

failure.  Ticket #1886. (CVS 3329)

FossilOrigin-Name: b1f326e6959ef3be11f772e80f5ab6dd65b2d065
This commit is contained in:
drh
2006-07-11 13:15:08 +00:00
parent 76f8079623
commit 206f3d96d1
5 changed files with 38 additions and 18 deletions

View File

@@ -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.318 2006/06/21 07:02:33 danielk1977 Exp $
** $Id: select.c,v 1.319 2006/07/11 13:15:08 drh Exp $
*/
#include "sqliteInt.h"
@@ -221,12 +221,17 @@ static void addWhereTerm(
zAlias2 = pTab2->zName;
}
pE2b = sqlite3CreateIdExpr(zAlias2);
pE1c = sqlite3Expr(TK_DOT, pE1b, pE1a, 0);
pE2c = sqlite3Expr(TK_DOT, pE2b, pE2a, 0);
pE = sqlite3Expr(TK_EQ, pE1c, pE2c, 0);
ExprSetProperty(pE, EP_FromJoin);
pE->iRightJoinTable = iRightJoinTable;
*ppExpr = sqlite3ExprAnd(*ppExpr, pE);
pE1c = sqlite3ExprOrFree(TK_DOT, pE1b, pE1a, 0);
pE2c = sqlite3ExprOrFree(TK_DOT, pE2b, pE2a, 0);
pE = sqlite3ExprOrFree(TK_EQ, pE1c, pE2c, 0);
if( pE ){
ExprSetProperty(pE, EP_FromJoin);
pE->iRightJoinTable = iRightJoinTable;
}
pE = sqlite3ExprAnd(*ppExpr, pE);
if( pE ){
*ppExpr = pE;
}
}
/*
@@ -2373,6 +2378,7 @@ static int simpleMinMaxQuery(Parse *pParse, Select *p, int eDest, int iParm){
pIdx = 0;
}else{
CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr);
if( pColl==0 ) return 0;
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
assert( pIdx->nColumn>=1 );
if( pIdx->aiColumn[0]==iCol &&