diff options
author | drh <drh@noemail.net> | 2011-10-14 21:49:18 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2011-10-14 21:49:18 +0000 |
commit | b07028f71cd96b48a81474c6f1eea9596eb41cc7 (patch) | |
tree | 79e9ce2fc70ef9318d48c388431caf117fbdf001 /src/expr.c | |
parent | 0edb7acd3c2dcd913e5cecce8475aed8ff0850bf (diff) | |
download | sqlite-b07028f71cd96b48a81474c6f1eea9596eb41cc7.tar.gz sqlite-b07028f71cd96b48a81474c6f1eea9596eb41cc7.zip |
Add assert() statements and eliminate needless variable assignments in order
to get the clang scan-build utility to report zero problems against the
SQLite core. Clang's static analysis did find one real problem - but it was
in the command-line shell, not in the SQLite core.
FossilOrigin-Name: 60fee9574b0125705787e33c16f116cf188c8323
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/expr.c b/src/expr.c index 3e144612c..d50617377 100644 --- a/src/expr.c +++ b/src/expr.c @@ -403,7 +403,8 @@ Expr *sqlite3ExprAlloc( }else{ int c; pNew->u.zToken = (char*)&pNew[1]; - memcpy(pNew->u.zToken, pToken->z, pToken->n); + assert( pToken->z!=0 || pToken->n==0 ); + if( pToken->n ) memcpy(pNew->u.zToken, pToken->z, pToken->n); pNew->u.zToken[pToken->n] = 0; if( dequote && nExtra>=3 && ((c = pToken->z[0])=='\'' || c=='"' || c=='[' || c=='`') ){ @@ -1442,11 +1443,19 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){ p = (ExprHasProperty(pX, EP_xIsSelect) ? pX->x.pSelect : 0); if( ALWAYS(pParse->nErr==0) && isCandidateForInOpt(p) ){ sqlite3 *db = pParse->db; /* Database connection */ - Expr *pExpr = p->pEList->a[0].pExpr; /* Expression <column> */ - int iCol = pExpr->iColumn; /* Index of column <column> */ Vdbe *v = sqlite3GetVdbe(pParse); /* Virtual machine being coded */ - Table *pTab = p->pSrc->a[0].pTab; /* Table <table>. */ + Table *pTab; /* Table <table>. */ + Expr *pExpr; /* Expression <column> */ + int iCol; /* Index of column <column> */ int iDb; /* Database idx for pTab */ + + assert( p ); /* Because of isCandidateForInOpt(p) */ + assert( p->pEList!=0 ); /* Because of isCandidateForInOpt(p) */ + assert( p->pEList->a[0].pExpr!=0 ); /* Because of isCandidateForInOpt(p) */ + assert( p->pSrc!=0 ); /* Because of isCandidateForInOpt(p) */ + pTab = p->pSrc->a[0].pTab; + pExpr = p->pEList->a[0].pExpr; + iCol = pExpr->iColumn; /* Code an OP_VerifyCookie and OP_TableLock for <table>. */ iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |