1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-24 08:21:29 +03:00

New assert() statements to verify that Expr.iColumn is never used as an

array index when its value is negative.

FossilOrigin-Name: 6084c5fb6d3fcedf35cd6c597a44ec7bf8b4a2576c7b277e5342d2a7905318e7
This commit is contained in:
drh
2023-05-17 15:46:46 +00:00
parent 9c9b33cbaf
commit 60fd5c34ab
5 changed files with 19 additions and 12 deletions

View File

@@ -226,14 +226,20 @@ Expr *sqlite3LimitWhere(
);
}else{
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
assert( pPk!=0 );
assert( pPk->nKeyCol>=1 );
if( pPk->nKeyCol==1 ){
const char *zName = pTab->aCol[pPk->aiColumn[0]].zCnName;
const char *zName;
assert( pPk->aiColumn[0]>=0 && pPk->aiColumn[0]<pTab->nCol );
zName = pTab->aCol[pPk->aiColumn[0]].zCnName;
pLhs = sqlite3Expr(db, TK_ID, zName);
pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ID, zName));
}else{
int i;
for(i=0; i<pPk->nKeyCol; i++){
Expr *p = sqlite3Expr(db, TK_ID, pTab->aCol[pPk->aiColumn[i]].zCnName);
Expr *p;
assert( pPk->aiColumn[i]>=0 && pPk->aiColumn[i]<pTab->nCol );
p = sqlite3Expr(db, TK_ID, pTab->aCol[pPk->aiColumn[i]].zCnName);
pEList = sqlite3ExprListAppend(pParse, pEList, p);
}
pLhs = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);