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 <rhermanklink@ripe.net>
pull/905/head
Robert Klink 2024-07-31 14:34:41 +02:00 zatwierdzone przez Damien George
rodzic 8d6ebf57a2
commit 0a65c3d34a
1 zmienionych plików z 5 dodań i 0 usunięć

Wyświetl plik

@ -84,6 +84,11 @@ class Cursor:
self.stmnt = None
def execute(self, sql, params=None):
if self.stmnt:
# If there is an existing statement, finalize that to free it
res = sqlite3_finalize(self.stmnt)
check_error(self.h, res)
if params:
params = [quote(v) for v in params]
sql = sql % tuple(params)