This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Potential leak in pysqlite_connection_init()
Type: resource usage Stage: resolved
Components: Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: lelit, mdk
Priority: normal Keywords:

Created on 2017-12-11 09:41 by lelit, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg308021 - (view) Author: Lele Gaifax (lelit) * Date: 2017-12-11 09:41
The function calls ``sqlite3_open()`` that, if I understand its documentation correctly[#], returns a new connection object in all cases (that is, even on errors) with the only exception of "out of memory" (in which case it sets the second parameter to ``NULL``).

I think that the new connection object should be immediately released in case of errors, passing it to ``sqlite3_close()``.

.. [#] http://sqlite.org/c3ref/open.html
msg308024 - (view) Author: Julien Palard (mdk) * (Python committer) Date: 2017-12-11 10:35
I don't see a leak here: as long as nobody keep a reference to each connection objects, pysqlite_connection_dealloc will be called and will call the sqlite3_close.

In other words the sqlite3_close is called when the connection is destroyed, which happen when no reference are kept on the connection, indifferently of a success or a failure of the connection.

It's in Modules/_sqlite/connection.c
msg308025 - (view) Author: Lele Gaifax (lelit) * Date: 2017-12-11 10:43
You are right, thank you.
History
Date User Action Args
2022-04-11 14:58:55adminsetgithub: 76455
2017-12-11 10:43:28lelitsetstatus: open -> closed
resolution: not a bug
messages: + msg308025

stage: resolved
2017-12-11 10:35:31mdksetnosy: + mdk
messages: + msg308024
2017-12-11 09:41:13lelitcreate