1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +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:
danielk1977
2007-04-19 11:09:01 +00:00
parent e960153ba2
commit 7e29e9561c
6 changed files with 41 additions and 22 deletions

View File

@ -14,7 +14,7 @@
# 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.
#
# $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]
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))
}
# 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.
do_test malloc-99.X {
catch {db close}