mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
c2b151c66e
commit
dc5af70631
2 changed files with 85 additions and 43 deletions
|
@ -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()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue