Index: src/alter.c ================================================================== --- src/alter.c +++ src/alter.c @@ -968,10 +968,11 @@ sParse.eParseMode = PARSE_MODE_RENAME_COLUMN; sParse.db = db; sParse.nQueryLoop = 1; rc = sqlite3RunParser(&sParse, zSql, &zErr); assert( sParse.pNewTable==0 || sParse.pNewIndex==0 ); + if( db->mallocFailed ) rc = SQLITE_NOMEM; if( rc==SQLITE_OK && sParse.pNewTable==0 && sParse.pNewIndex==0 ){ rc = SQLITE_CORRUPT_BKPT; } if( rc==SQLITE_OK ){ @@ -988,12 +989,11 @@ sqlite3_result_error(context, zErr, -1); }else{ sqlite3_result_error_code(context, rc); } sqlite3DbFree(db, zErr); - sqlite3_free(zQuot); - return; + goto renameColumnFunc_done; } if( bQuote ){ zNew = zQuot; nNew = nQuot; @@ -1092,10 +1092,11 @@ sqlite3_result_text(context, zOut, -1, SQLITE_TRANSIENT); sqlite3DbFree(db, zOut); } +renameColumnFunc_done: if( sParse.pVdbe ){ sqlite3VdbeFinalize(sParse.pVdbe); } sqlite3DeleteTable(db, sParse.pNewTable); if( sParse.pNewIndex ) sqlite3FreeIndex(db, sParse.pNewIndex); Index: src/parse.y ================================================================== --- src/parse.y +++ src/parse.y @@ -1309,11 +1309,11 @@ ){ sqlite3ErrorMsg(pParse, "syntax error after column name \"%.*s\"", pIdToken->n, pIdToken->z); } sqlite3ExprListSetName(pParse, p, pIdToken, 1); - if( IN_RENAME_COLUMN ){ + if( IN_RENAME_COLUMN && p ){ sqlite3RenameToken(pParse, (void*)(p->a[p->nExpr-1].zName), pIdToken); } return p; } } // end %include