1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-19 21:43:15 +03:00

Fix a case when a pointer might be used after being freed in the ALTER TABLE code. Fix for [4722bdab08cb1].

FossilOrigin-Name: d09f8c3621d5f7f8c6d99d7d82bcaa8421855b3f470bea2b26c858106382b906
This commit is contained in:
dan
2020-04-03 11:20:40 +00:00
parent 91654b2016
commit fb99e388ec
4 changed files with 37 additions and 9 deletions

View File

@@ -755,6 +755,21 @@ static void renameWalkWith(Walker *pWalker, Select *pSelect){
}
}
/*
** Unmap all tokens in the IdList object passed as the second argument.
*/
static void unmapColumnIdlistNames(
Parse *pParse,
IdList *pIdList
){
if( pIdList ){
int ii;
for(ii=0; ii<pIdList->nId; ii++){
sqlite3RenameTokenRemap(pParse, 0, (void*)pIdList->a[ii].zName);
}
}
}
/*
** Walker callback used by sqlite3RenameExprUnmap().
*/
@@ -776,6 +791,7 @@ static int renameUnmapSelectCb(Walker *pWalker, Select *p){
for(i=0; i<pSrc->nSrc; i++){
sqlite3RenameTokenRemap(pParse, 0, (void*)pSrc->a[i].zName);
if( sqlite3WalkExpr(pWalker, pSrc->a[i].pOn) ) return WRC_Abort;
unmapColumnIdlistNames(pParse, pSrc->a[i].pUsing);
}
}
@@ -984,6 +1000,7 @@ static void renameColumnIdlistNames(
}
}
/*
** Parse the SQL statement zSql using Parse object (*p). The Parse object
** is initialized by this function before it is used.