From: danielk1977 Date: Tue, 23 Nov 2004 16:31:16 +0000 (+0000) Subject: Fix a memory leak in ALTER TABLE. (CVS 2149) X-Git-Tag: version-3.6.10~4003 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8b840013dacdf376469e805f241b0379cc8d1d27;p=thirdparty%2Fsqlite.git Fix a memory leak in ALTER TABLE. (CVS 2149) FossilOrigin-Name: ba71716ce21ae99b10b2d0b61092497872770ef7 --- diff --git a/manifest b/manifest index 9651877d6d..3718e1d1c3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sauthorization\scallbacks\sfor\sREINDEX.\s(CVS\s2148) -D 2004-11-23T15:41:16 +C Fix\sa\smemory\sleak\sin\sALTER\sTABLE.\s(CVS\s2149) +D 2004-11-23T16:31:17 F Makefile.in 8291610f5839939a5fbff4dbbf85adb0fe1ac37f F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1 @@ -31,7 +31,7 @@ F src/attach.c e49d09dad9f5f9fb10b4b0c1be5a70ae4c45e689 F src/auth.c 3b81f2a42f48a62c2c9c9b0eda31a157c681edea F src/btree.c fa113d624d38bcb36700a0244b47f39d57d34efb F src/btree.h 861e40b759a195ba63819740e484390012cf81ab -F src/build.c cbfb818055aacb2d53fbb7c801d8815439395f3f +F src/build.c aa7975d778491ab144ae3921a7791cd51a733e8b F src/cursor.c f883813759742068890b1f699335872bfa8fdf41 F src/date.c 65536e7ea04fdde6e0551264fca15966966e171f F src/delete.c 9083377a4c5b152b4466021592f32e3e8a3819e3 @@ -261,7 +261,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25 F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c -P 3053d82d7192ff77ff5f1fee143d784d5d51772a -R a49bc02d1fdd0d416a9fe44ea293a6c3 +P 9f0d744ee4d99f44e88c6f799821791c3b5f31b6 +R 03f725c22a09099554b36400e4198cba U danielk1977 -Z 84fb8419b6155b0b4da06bd874aa57f4 +Z 4e08678bf69c6bd3c7b9d609af7bdaeb diff --git a/manifest.uuid b/manifest.uuid index 04ae1c8996..7fff850a38 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9f0d744ee4d99f44e88c6f799821791c3b5f31b6 \ No newline at end of file +ba71716ce21ae99b10b2d0b61092497872770ef7 \ No newline at end of file diff --git a/src/build.c b/src/build.c index df427712f2..beff06c986 100644 --- a/src/build.c +++ b/src/build.c @@ -22,7 +22,7 @@ ** COMMIT ** ROLLBACK ** -** $Id: build.c,v 1.287 2004/11/23 15:41:16 danielk1977 Exp $ +** $Id: build.c,v 1.288 2004/11/23 16:31:17 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -2956,13 +2956,13 @@ void sqlite3AlterRenameTable( assert( pSrc->nSrc==1 ); pTab = sqlite3LocateTable(pParse, pSrc->a[0].zName, pSrc->a[0].zDatabase); - if( !pTab ) return; + if( !pTab ) goto exit_alter_table; iDb = pTab->iDb; zDb = db->aDb[iDb].zName; /* Get a NULL terminated version of the new table name. */ zName = sqlite3NameFromToken(pName); - if( !zName ) return; + if( !zName ) goto exit_alter_table; /* Check that a table or index named 'zName' does not already exist ** in database iDb. If so, this is an error. @@ -2970,8 +2970,7 @@ void sqlite3AlterRenameTable( if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){ sqlite3ErrorMsg(pParse, "there is already another table or index with this name: %s", zName); - sqliteFree(zName); - return; + goto exit_alter_table; } /* Make sure it is not a system table being altered, or a reserved name @@ -2979,19 +2978,16 @@ void sqlite3AlterRenameTable( */ if( strlen(pTab->zName)>6 && 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7) ){ sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName); - sqliteFree(zName); - return; + goto exit_alter_table; } if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ - sqliteFree(zName); - return; + goto exit_alter_table; } #ifndef SQLITE_OMIT_AUTHORIZATION /* Invoke the authorization callback. */ if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){ - sqliteFree(zName); - return; + goto exit_alter_table; } #endif @@ -3001,8 +2997,7 @@ void sqlite3AlterRenameTable( */ v = sqlite3GetVdbe(pParse); if( v==0 ){ - sqliteFree(zName); - return; + goto exit_alter_table; } sqlite3BeginWriteOperation(pParse, 0, iDb); sqlite3ChangeCookie(db, v, iDb); @@ -3098,6 +3093,8 @@ zName, #endif } +exit_alter_table: + sqlite3SrcListDelete(pSrc); sqliteFree(zName); } #endif