aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <dan@noemail.net>2020-04-03 11:20:40 +0000
committerdan <dan@noemail.net>2020-04-03 11:20:40 +0000
commitfb99e388ec7f30fe43e4878236e3695ff24ae58d (patch)
treed8157c52426ed29c95644e8537196fe34447ed28 /src
parent91654b20166402bbd6214c2c793e4b94459f46fb (diff)
downloadsqlite-fb99e388ec7f30fe43e4878236e3695ff24ae58d.tar.gz
sqlite-fb99e388ec7f30fe43e4878236e3695ff24ae58d.zip
Fix a case when a pointer might be used after being freed in the ALTER TABLE code. Fix for [4722bdab08cb1].
FossilOrigin-Name: d09f8c3621d5f7f8c6d99d7d82bcaa8421855b3f470bea2b26c858106382b906
Diffstat (limited to 'src')
-rw-r--r--src/alter.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/alter.c b/src/alter.c
index ee193d18b..7114757a2 100644
--- a/src/alter.c
+++ b/src/alter.c
@@ -756,6 +756,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().
*/
static int renameUnmapSelectCb(Walker *pWalker, Select *p){
@@ -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.