Skip to content

Commit 0a65c3d

Browse files
rhermanklinkdpgeorge
authored andcommitted
unix-ffi/sqlite3: Fix statements not being finalized.
Currently, statements are only finalized upon a call to Cursor.close(). However, in Cursor.execute() new statements get created without the previous statements being finalized, causing those to get leaked, preventing the database from being closed. The fix addresses this by finalizing the previous statement if it exists. Signed-off-by: Robert Klink <[email protected]>
1 parent 8d6ebf5 commit 0a65c3d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

unix-ffi/sqlite3/sqlite3.py

+5
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ def __init__(self, h):
8484
self.stmnt = None
8585

8686
def execute(self, sql, params=None):
87+
if self.stmnt:
88+
# If there is an existing statement, finalize that to free it
89+
res = sqlite3_finalize(self.stmnt)
90+
check_error(self.h, res)
91+
8792
if params:
8893
params = [quote(v) for v in params]
8994
sql = sql % tuple(params)

0 commit comments

Comments
 (0)