1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-16 23:02:26 +03:00

Fix a crash in new ALTER TABLE code that could follow an OOM.

FossilOrigin-Name: 6f1f2a0a9cd75ca43b81cc325296b843ccefe6f8040da8f2e873f49928423f10
This commit is contained in:
dan
2021-06-11 12:14:58 +00:00
parent 6065686d9c
commit d03d3a9b74
4 changed files with 41 additions and 19 deletions

View File

@@ -812,18 +812,19 @@ static void renameWalkWith(Walker *pWalker, Select *pSelect){
assert( pWith->nCte>0 );
assert( (pWith->a[0].pSelect->selFlags & SF_Expanded)==0 );
pCopy = sqlite3WithDup(pParse->db, pWith);
sqlite3WithPush(pParse, pCopy, 1);
for(i=0; i<pWith->nCte; i++){
Select *p = pWith->a[i].pSelect;
NameContext sNC;
memset(&sNC, 0, sizeof(sNC));
sNC.pParse = pParse;
sqlite3SelectPrep(sNC.pParse, p, &sNC);
sqlite3WalkSelect(pWalker, p);
sqlite3RenameExprlistUnmap(pParse, pWith->a[i].pCols);
if( pCopy ){
sqlite3WithPush(pParse, pCopy, 1);
for(i=0; i<pWith->nCte; i++){
Select *p = pWith->a[i].pSelect;
NameContext sNC;
memset(&sNC, 0, sizeof(sNC));
sNC.pParse = pParse;
sqlite3SelectPrep(sNC.pParse, p, &sNC);
sqlite3WalkSelect(pWalker, p);
sqlite3RenameExprlistUnmap(pParse, pWith->a[i].pCols);
}
pParse->pWith = pCopy->pOuter;
}
pParse->pWith = pCopy->pOuter;
}
}