/ Check-in [16205302]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Make sure WhereClause objects are fully initialized before use when planning OR queries.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 162053021795ff40c447498a76de4d31d58aa808
User & Date: drh 2016-02-19 14:10:44
Context
2016-02-19
14:20
Fix a harmless uninitialized variable access. check-in: 398522e6 user: drh tags: trunk
14:10
Make sure WhereClause objects are fully initialized before use when planning OR queries. check-in: 16205302 user: drh tags: trunk
13:29
Fix (harmless) compiler warnings in some of the TCL-based test code. check-in: 7c26d2b4 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/whereexpr.c.

   529    529     */
   530    530     assert( (pTerm->wtFlags & (TERM_DYNAMIC|TERM_ORINFO|TERM_ANDINFO))==0 );
   531    531     assert( pExpr->op==TK_OR );
   532    532     pTerm->u.pOrInfo = pOrInfo = sqlite3DbMallocZero(db, sizeof(*pOrInfo));
   533    533     if( pOrInfo==0 ) return;
   534    534     pTerm->wtFlags |= TERM_ORINFO;
   535    535     pOrWc = &pOrInfo->wc;
          536  +  memset(pOrWc->aStatic, 0, sizeof(pOrWc->aStatic));
   536    537     sqlite3WhereClauseInit(pOrWc, pWInfo);
   537    538     sqlite3WhereSplit(pOrWc, pExpr, TK_OR);
   538    539     sqlite3WhereExprAnalyze(pSrc, pOrWc);
   539    540     if( db->mallocFailed ) return;
   540    541     assert( pOrWc->nTerm>=2 );
   541    542   
   542    543     /*
................................................................................
   555    556           WhereTerm *pAndTerm;
   556    557           int j;
   557    558           Bitmask b = 0;
   558    559           pOrTerm->u.pAndInfo = pAndInfo;
   559    560           pOrTerm->wtFlags |= TERM_ANDINFO;
   560    561           pOrTerm->eOperator = WO_AND;
   561    562           pAndWC = &pAndInfo->wc;
          563  +        memset(pAndWC->aStatic, 0, sizeof(pAndWC->aStatic));
   562    564           sqlite3WhereClauseInit(pAndWC, pWC->pWInfo);
   563    565           sqlite3WhereSplit(pAndWC, pOrTerm->pExpr, TK_AND);
   564    566           sqlite3WhereExprAnalyze(pSrc, pAndWC);
   565    567           pAndWC->pOuter = pWC;
   566    568           if( !db->mallocFailed ){
   567    569             for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){
   568    570               assert( pAndTerm->pExpr );