1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Fix a problem where a file was not being closed after a malloc() failure. (CVS 1741)

FossilOrigin-Name: 3c8512bc549e10ee131cb7f2d4e74d96e9de74a0
This commit is contained in:
danielk1977
2004-06-26 13:51:33 +00:00
parent 3dea76474c
commit b5548a8b20
5 changed files with 53 additions and 19 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.8 2004/06/19 00:16:31 drh Exp $
# $Id: malloc.test,v 1.9 2004/06/26 13:51:34 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -65,6 +65,12 @@ for {set go 1; set i 1} {$go} {incr i} {
} {1 1}
}
# Ensure that no file descriptors were leaked.
do_test malloc-1.X {
catch {db close}
set sqlite_open_file_count
} {0}
set fd [open ./data.tmp w]
for {set i 1} {$i<=20} {incr i} {
puts $fd "$i\t[expr {$i*$i}]\t[expr {100-$i}] abcdefghijklmnopqrstuvwxyz"
@ -115,6 +121,12 @@ for {set go 1; set i 1} {$go} {incr i} {
} {1 1}
}
# Ensure that no file descriptors were leaked.
do_test malloc-2.X {
catch {db close}
set sqlite_open_file_count
} {0}
for {set go 1; set i 1} {$go} {incr i} {
do_test malloc-3.$i {
sqlite_malloc_fail 0
@ -155,6 +167,13 @@ for {set go 1; set i 1} {$go} {incr i} {
}
} {1 1}
}
# Ensure that no file descriptors were leaked.
do_test malloc-3.X {
catch {db close}
set sqlite_open_file_count
} {0}
for {set go 1; set i 1} {$go} {incr i} {
do_test malloc-4.$i {
sqlite_malloc_fail 0
@ -196,6 +215,13 @@ for {set go 1; set i 1} {$go} {incr i} {
}
} {1 1}
}
# Ensure that no file descriptors were leaked.
do_test malloc-4.X {
catch {db close}
set sqlite_open_file_count
} {0}
for {set go 1; set i 1} {$go} {incr i} {
do_test malloc-5.$i {
sqlite_malloc_fail 0
@ -230,5 +256,12 @@ for {set go 1; set i 1} {$go} {incr i} {
}
} {1 1}
}
# Ensure that no file descriptors were leaked.
do_test malloc-5.X {
catch {db close}
set sqlite_open_file_count
} {0}
sqlite_malloc_fail 0
finish_test