mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-10 01:02:56 +03:00
Ensure that the Expr objects that describe indexed expressions are not modified
by code generation. Fix for an assert() problem found by Jon Metzman using AFL. FossilOrigin-Name: 34073ce87d88a02313217023ae92e15939192cd9
This commit is contained in:
16
src/expr.c
16
src/expr.c
@@ -2468,7 +2468,7 @@ void sqlite3ExprCodeLoadIndexColumn(
|
||||
assert( pIdx->aColExpr );
|
||||
assert( pIdx->aColExpr->nExpr>iIdxCol );
|
||||
pParse->iSelfTab = iTabCur;
|
||||
sqlite3ExprCode(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);
|
||||
sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);
|
||||
}else{
|
||||
sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,
|
||||
iTabCol, regOut);
|
||||
@@ -3321,13 +3321,25 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){
|
||||
sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target);
|
||||
}else{
|
||||
inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
|
||||
assert( pParse->pVdbe || pParse->db->mallocFailed );
|
||||
assert( pParse->pVdbe!=0 || pParse->db->mallocFailed );
|
||||
if( inReg!=target && pParse->pVdbe ){
|
||||
sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Make a transient copy of expression pExpr and then code it using
|
||||
** sqlite3ExprCode(). This routine works just like sqlite3ExprCode()
|
||||
** except that the input expression is guaranteed to be unchanged.
|
||||
*/
|
||||
void sqlite3ExprCodeCopy(Parse *pParse, Expr *pExpr, int target){
|
||||
sqlite3 *db = pParse->db;
|
||||
pExpr = sqlite3ExprDup(db, pExpr, 0);
|
||||
if( !db->mallocFailed ) sqlite3ExprCode(pParse, pExpr, target);
|
||||
sqlite3ExprDelete(db, pExpr);
|
||||
}
|
||||
|
||||
/*
|
||||
** Generate code that will evaluate expression pExpr and store the
|
||||
** results in register target. The results are guaranteed to appear
|
||||
|
Reference in New Issue
Block a user