mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-01 06:27:03 +03:00
Fix a bug whereby sqlite3_prepare_v2() could return both an out-of-memory error and a valid statement handle. (CVS 3858)
FossilOrigin-Name: 8795d11c3c5bb39d34bc5194621ce97097a320e7
This commit is contained in:
20
manifest
20
manifest
@ -1,5 +1,5 @@
|
|||||||
C Get\sthe\sbuild\sworking\swith\sSQLITE_OMIT_SHARED_CACHE.\s\sTicket\s#2307.\s(CVS\s3857)
|
C Fix\sa\sbug\swhereby\ssqlite3_prepare_v2()\scould\sreturn\sboth\san\sout-of-memory\serror\sand\sa\svalid\sstatement\shandle.\s(CVS\s3858)
|
||||||
D 2007-04-19T00:24:34
|
D 2007-04-19T11:09:01
|
||||||
F Makefile.in 8cab54f7c9f5af8f22fd97ddf1ecfd1e1860de62
|
F Makefile.in 8cab54f7c9f5af8f22fd97ddf1ecfd1e1860de62
|
||||||
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
||||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||||
@ -90,7 +90,7 @@ F src/pager.c 33c632ce9c228d87f14879a139fa123d43e4bf25
|
|||||||
F src/pager.h d652ddf092d2318d00e41f8539760fe8e57c157c
|
F src/pager.h d652ddf092d2318d00e41f8539760fe8e57c157c
|
||||||
F src/parse.y b6cfbadb6d5b21b5087d30698ee5af0ebb098767
|
F src/parse.y b6cfbadb6d5b21b5087d30698ee5af0ebb098767
|
||||||
F src/pragma.c 3b992b5b2640d6ae25cef05aa6a42cd1d6c43234
|
F src/pragma.c 3b992b5b2640d6ae25cef05aa6a42cd1d6c43234
|
||||||
F src/prepare.c 37207b2b2ccb41d379b01dd62231686bcc48ef1f
|
F src/prepare.c 4cb9c9eb926e8baf5652ca4b4f2416f53f5b5370
|
||||||
F src/printf.c 0c6f40648770831341ac45ab32423a80b4c87f05
|
F src/printf.c 0c6f40648770831341ac45ab32423a80b4c87f05
|
||||||
F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
|
F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
|
||||||
F src/select.c b914abca0ba28893e7fb7c7fb97a05e240e2ce8b
|
F src/select.c b914abca0ba28893e7fb7c7fb97a05e240e2ce8b
|
||||||
@ -101,7 +101,7 @@ F src/sqlite3ext.h 7d0d363ea7327e817ef0dfe1b7eee1f171b72890
|
|||||||
F src/sqliteInt.h 047af0e4c38bbb8652836f72adc9e9199c51a1ba
|
F src/sqliteInt.h 047af0e4c38bbb8652836f72adc9e9199c51a1ba
|
||||||
F src/table.c 6d0da66dde26ee75614ed8f584a1996467088d06
|
F src/table.c 6d0da66dde26ee75614ed8f584a1996467088d06
|
||||||
F src/tclsqlite.c ec69eb9ad56d03fbf7570ca1ca5ea947d1ec4b6f
|
F src/tclsqlite.c ec69eb9ad56d03fbf7570ca1ca5ea947d1ec4b6f
|
||||||
F src/test1.c b96f80e68cd50e10e10cda8bb762152bae52a8d2
|
F src/test1.c 3a7810d1ff8829268bd52a91c4f29d66f693e431
|
||||||
F src/test2.c 24458b17ab2f3c90cbc1c8446bd7ffe69be62f88
|
F src/test2.c 24458b17ab2f3c90cbc1c8446bd7ffe69be62f88
|
||||||
F src/test3.c 65f92247cf8592854e9bf5115b3fb711f8b33280
|
F src/test3.c 65f92247cf8592854e9bf5115b3fb711f8b33280
|
||||||
F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
|
F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
|
||||||
@ -265,7 +265,7 @@ F test/lock2.test b95915eb4b6f8420acb30c68170d8f0ed9364efe
|
|||||||
F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
|
F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
|
||||||
F test/lock4.test 49e22396b9be6e047b3d35469f233be79153c9d5
|
F test/lock4.test 49e22396b9be6e047b3d35469f233be79153c9d5
|
||||||
F test/main.test e7212ce1023957c7209778cc87fa932bd79ba89a
|
F test/main.test e7212ce1023957c7209778cc87fa932bd79ba89a
|
||||||
F test/malloc.test d868a6b98b07928b00bca3d9874daf6885c86150
|
F test/malloc.test c468c018eecba78d1832cb9aaa23a7f824f07179
|
||||||
F test/malloc2.test 4ed7d719542c4570dec9c2ebe2bbdf3a9f3b0d05
|
F test/malloc2.test 4ed7d719542c4570dec9c2ebe2bbdf3a9f3b0d05
|
||||||
F test/malloc3.test e965954b6f808876a63d3101fd70370320b509a7
|
F test/malloc3.test e965954b6f808876a63d3101fd70370320b509a7
|
||||||
F test/malloc4.test 59cd02f71b363302a04c4e77b97c0a1572eaa210
|
F test/malloc4.test 59cd02f71b363302a04c4e77b97c0a1572eaa210
|
||||||
@ -378,7 +378,7 @@ F test/vtab6.test ec0036f29f8a803da9935206f2d9d1b6a8026392
|
|||||||
F test/vtab7.test 5f9ef9fb84733e928d5d0267c821072561b198d5
|
F test/vtab7.test 5f9ef9fb84733e928d5d0267c821072561b198d5
|
||||||
F test/vtab8.test e19fa4a538fcd1bb66c22825fa8f71618fb13583
|
F test/vtab8.test e19fa4a538fcd1bb66c22825fa8f71618fb13583
|
||||||
F test/vtab9.test ea58d2b95d61955f87226381716b2d0b1d4e4f9b
|
F test/vtab9.test ea58d2b95d61955f87226381716b2d0b1d4e4f9b
|
||||||
F test/vtab_err.test 224cc80ad700797c48b9cd2c1e0bd7a8517d8609
|
F test/vtab_err.test 9eabf98b26838fed8bac4aea986580be0a2bd52e
|
||||||
F test/vtab_shared.test d631d1f820c38c18939d53aab1fc35db5f0a8094
|
F test/vtab_shared.test d631d1f820c38c18939d53aab1fc35db5f0a8094
|
||||||
F test/where.test 1d020f50c77f37b2dbab9766ca959e6e3278ecdb
|
F test/where.test 1d020f50c77f37b2dbab9766ca959e6e3278ecdb
|
||||||
F test/where2.test 3249d426b3fc7a106713d784e1628307fc308d2e
|
F test/where2.test 3249d426b3fc7a106713d784e1628307fc308d2e
|
||||||
@ -459,7 +459,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
|||||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||||
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
||||||
P 7f9f0444ed1a85ed682b604fded535bff5be1535
|
P b623538c559498b858fd9088faf0f3457b024968
|
||||||
R d187fdd647c1916ac20a959baddf7f62
|
R 34a9c9622b6327def09bfe5f09cfc0a2
|
||||||
U drh
|
U danielk1977
|
||||||
Z 0e43a1980a04cbafd526518137be335c
|
Z bae87dbb6b82dc5bb5cdcc29876b1ea7
|
||||||
|
@ -1 +1 @@
|
|||||||
b623538c559498b858fd9088faf0f3457b024968
|
8795d11c3c5bb39d34bc5194621ce97097a320e7
|
@ -13,7 +13,7 @@
|
|||||||
** interface, and routines that contribute to loading the database schema
|
** interface, and routines that contribute to loading the database schema
|
||||||
** from disk.
|
** from disk.
|
||||||
**
|
**
|
||||||
** $Id: prepare.c,v 1.45 2007/03/26 22:05:02 drh Exp $
|
** $Id: prepare.c,v 1.46 2007/04/19 11:09:01 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
@ -537,13 +537,15 @@ int sqlite3Prepare(
|
|||||||
if( sqlite3SafetyOff(db) ){
|
if( sqlite3SafetyOff(db) ){
|
||||||
rc = SQLITE_MISUSE;
|
rc = SQLITE_MISUSE;
|
||||||
}
|
}
|
||||||
if( rc==SQLITE_OK ){
|
|
||||||
if( saveSqlFlag ){
|
if( saveSqlFlag ){
|
||||||
sqlite3VdbeSetSql(sParse.pVdbe, zSql, sParse.zTail - zSql);
|
sqlite3VdbeSetSql(sParse.pVdbe, zSql, sParse.zTail - zSql);
|
||||||
}
|
}
|
||||||
*ppStmt = (sqlite3_stmt*)sParse.pVdbe;
|
if( rc!=SQLITE_OK || sqlite3MallocFailed() ){
|
||||||
}else if( sParse.pVdbe ){
|
|
||||||
sqlite3_finalize((sqlite3_stmt*)sParse.pVdbe);
|
sqlite3_finalize((sqlite3_stmt*)sParse.pVdbe);
|
||||||
|
assert(!(*ppStmt));
|
||||||
|
}else{
|
||||||
|
*ppStmt = (sqlite3_stmt*)sParse.pVdbe;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( zErrMsg ){
|
if( zErrMsg ){
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
** is not included in the SQLite library. It is used for automated
|
** is not included in the SQLite library. It is used for automated
|
||||||
** testing of the SQLite library.
|
** testing of the SQLite library.
|
||||||
**
|
**
|
||||||
** $Id: test1.c,v 1.237 2007/04/13 02:14:30 drh Exp $
|
** $Id: test1.c,v 1.238 2007/04/19 11:09:02 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "tcl.h"
|
#include "tcl.h"
|
||||||
@ -2748,6 +2748,7 @@ static int test_prepare_v2(
|
|||||||
if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR;
|
if( Tcl_GetIntFromObj(interp, objv[3], &bytes) ) return TCL_ERROR;
|
||||||
|
|
||||||
rc = sqlite3_prepare_v2(db, zSql, bytes, &pStmt, &zTail);
|
rc = sqlite3_prepare_v2(db, zSql, bytes, &pStmt, &zTail);
|
||||||
|
assert(rc==SQLITE_OK || pStmt==0);
|
||||||
if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;
|
if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;
|
||||||
if( zTail ){
|
if( zTail ){
|
||||||
if( bytes>=0 ){
|
if( bytes>=0 ){
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# special feature is used to see what happens in the library if a malloc
|
# special feature is used to see what happens in the library if a malloc
|
||||||
# were to really fail due to an out-of-memory situation.
|
# were to really fail due to an out-of-memory situation.
|
||||||
#
|
#
|
||||||
# $Id: malloc.test,v 1.40 2007/03/30 07:10:52 danielk1977 Exp $
|
# $Id: malloc.test,v 1.41 2007/04/19 11:09:02 danielk1977 Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@ -552,6 +552,23 @@ do_malloc_test 21 -sqlbody {
|
|||||||
CREATE TABLE abc(a, b, c, FOREIGN KEY(a) REFERENCES abc(b))
|
CREATE TABLE abc(a, b, c, FOREIGN KEY(a) REFERENCES abc(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Test malloc failure in an sqlite3_prepare_v2() call.
|
||||||
|
#
|
||||||
|
do_malloc_test 22 -tclbody {
|
||||||
|
set ::STMT ""
|
||||||
|
set r [catch {
|
||||||
|
set ::STMT [
|
||||||
|
sqlite3_prepare_v2 $::DB "SELECT * FROM sqlite_master" -1 DUMMY
|
||||||
|
]
|
||||||
|
} msg]
|
||||||
|
if {$r} {error [string range $msg 4 end]}
|
||||||
|
} -cleanup {
|
||||||
|
if {$::STMT ne ""} {
|
||||||
|
sqlite3_finalize $::STMT
|
||||||
|
set ::STMT ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Ensure that no file descriptors were leaked.
|
# Ensure that no file descriptors were leaked.
|
||||||
do_test malloc-99.X {
|
do_test malloc-99.X {
|
||||||
catch {db close}
|
catch {db close}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#
|
#
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
#
|
#
|
||||||
# $Id: vtab_err.test,v 1.4 2007/01/02 18:41:58 drh Exp $
|
# $Id: vtab_err.test,v 1.5 2007/04/19 11:09:02 danielk1977 Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@ -146,7 +146,6 @@ do_ioerr_test vtab_err-1 -tclprep {
|
|||||||
COMMIT;
|
COMMIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
do_malloc_test vtab_err-2 -tclprep {
|
do_malloc_test vtab_err-2 -tclprep {
|
||||||
register_echo_module [sqlite3_connection_pointer db]
|
register_echo_module [sqlite3_connection_pointer db]
|
||||||
} -sqlbody {
|
} -sqlbody {
|
||||||
|
Reference in New Issue
Block a user