Fixes for problems following OOM errors.
FossilOrigin-Name: 9041ee4a6f0e8389297f887f1431ab5cfe783390
diff --git a/src/expr.c b/src/expr.c
index bd2426a..ac67eca 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -406,8 +406,11 @@
** with the same pLeft pointer to the pVector, but only one of them
** will own the pVector.
*/
- pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, pVector, 0, 0);
- if( pRet ) pRet->iColumn = iField;
+ pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0, 0);
+ if( pRet ){
+ pRet->iColumn = iField;
+ pRet->pLeft = pVector;
+ }
assert( pRet==0 || pRet->iTable==0 );
}else{
if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;
@@ -462,7 +465,8 @@
int *pRegFree /* OUT: Temp register to free */
){
assert( pVector->op==TK_VECTOR || pVector->op==TK_SELECT );
- assert( pParse->nErr || (pVector->op==TK_VECTOR)==(regSelect==0) );
+ assert( pParse->nErr || pParse->db->mallocFailed
+ || (pVector->op==TK_VECTOR)==(regSelect==0) );
if( pVector->op==TK_SELECT ){
*ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr;
return regSelect+iField;