1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Correctly allocate new columns array in ALTER TABLE .. ADD COLUMN. Ticket #1183. (CVS 2419)

FossilOrigin-Name: 3c86e63389b286a49106d8d7009cc63e3914d40f
This commit is contained in:
danielk1977
2005-03-27 01:56:30 +00:00
parent d960d0641e
commit b3a2cced6b
4 changed files with 41 additions and 14 deletions

View File

@@ -12,7 +12,7 @@
** This file contains C code routines that used to generate VDBE code
** that implements the ALTER TABLE command.
**
** $Id: alter.c,v 1.4 2005/03/19 14:45:49 drh Exp $
** $Id: alter.c,v 1.5 2005/03/27 01:56:31 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -521,7 +521,9 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
if( !pNew ) goto exit_begin_add_column;
pParse->pNewTable = pNew;
pNew->nCol = pTab->nCol;
nAlloc = ((pNew->nCol)/8)+8;
assert( pNew->nCol>0 );
nAlloc = (((pNew->nCol-1)/8)*8)+8;
assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );
pNew->aCol = (Column *)sqliteMalloc(sizeof(Column)*nAlloc);
pNew->zName = sqliteStrDup(pTab->zName);
if( !pNew->aCol || !pNew->zName ){