summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb/test
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2004-06-27 23:32:34 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2004-06-27 23:32:34 (GMT)
commitdc5af70631c86723132518152ce5f910848d83ae (patch)
treeb7f34b5ca26308a06dd352d34fc800ac8fe661e9 /Lib/bsddb/test
parentc2b151c66ee9bc6e686400ee93e65e07d1999888 (diff)
downloadcpython-dc5af70631c86723132518152ce5f910848d83ae.zip
cpython-dc5af70631c86723132518152ce5f910848d83ae.tar.gz
cpython-dc5af70631c86723132518152ce5f910848d83ae.tar.bz2
SF patch / bug #967763
Fix memory leaks revealed by valgrind and ensuing code inspection. In the existing test suite valgrind revealed two memory leaks (DB_get and DBC_set_range). Code inspection revealed that there were many other potential similar leaks (many on odd code error paths such as passing something other than a DBTxn object for a txn= parameter or in the face of an out of memory error). The most common case that would cause a leak was when using recno or queue format databases with integer keys, sometimes only with an exception exit.
Diffstat (limited to 'Lib/bsddb/test')
-rw-r--r--Lib/bsddb/test/test_recno.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/bsddb/test/test_recno.py b/Lib/bsddb/test/test_recno.py
index 87446d3..56a79c7 100644
--- a/Lib/bsddb/test/test_recno.py
+++ b/Lib/bsddb/test/test_recno.py
@@ -133,6 +133,13 @@ class SimpleRecnoTestCase(unittest.TestCase):
if verbose:
print rec
+ # test that non-existant key lookups work (and that
+ # DBC_set_range doesn't have a memleak under valgrind)
+ rec = c.set_range(999999)
+ assert rec == None
+ if verbose:
+ print rec
+
c.close()
d.close()
@@ -177,6 +184,8 @@ class SimpleRecnoTestCase(unittest.TestCase):
"""
source = os.path.join(os.path.dirname(sys.argv[0]),
'db_home/test_recno.txt')
+ if not os.path.isdir('db_home'):
+ os.mkdir('db_home')
f = open(source, 'w') # create the file
f.close()