8000 [3.9] bpo-40737: Fix possible reference leak for sqlite3 initialization (GH-20323) by miss-islington · Pull Request #20425 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.9] bpo-40737: Fix possible reference leak for sqlite3 initialization (GH-20323) #20425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bpo-40737: Fix possible reference leak for sqlite3 initialization (GH…
…-20323)

(cherry picked from commit 5eb45d7)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
  • Loading branch information
Erlend Egeberg Aasland authored and miss-islington committed May 26, 2020
commit 511f7f548a00c775897bddf5a565e17519ffbd76
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix possible reference leak for :mod:`sqlite3` initialization.
20 changes: 12 additions & 8 deletions Modules/_sqlite/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ static struct PyModuleDef _sqlite3module = {
NULL
};

#define ADD_TYPE(module, type) \
do { \
if (PyModule_AddType(module, &type) < 0) { \
Py_DECREF(module); \
return NULL; \
} \
} while (0)

PyMODINIT_FUNC PyInit__sqlite3(void)
{
PyObject *module, *dict;
Expand All @@ -366,14 +374,10 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
return NULL;
}

Py_INCREF(&pysqlite_ConnectionType);
PyModule_AddObject(module, "Connection", (PyObject*) &pysqlite_ConnectionType);
Py_INCREF(&pysqlite_CursorType);
PyModule_AddObject(module, "Cursor", (PyObject*) &pysqlite_CursorType);
Py_INCREF(&pysqlite_PrepareProtocolType);
PyModule_AddObject(module, "PrepareProtocol", (PyObject*) &pysqlite_PrepareProtocolType);
Py_INCREF(&pysqlite_RowType);
PyModule_AddObject(module, "Row", (PyObject*) &pysqlite_RowType);
ADD_TYPE(module, pysqlite_ConnectionType);
ADD_TYPE(module, pysqlite_CursorType);
ADD_TYPE(module, pysqlite_PrepareProtocolType);
ADD_TYPE(module, pysqlite_RowType);

if (!(dict = PyModule_GetDict(module))) {
goto error;
Expand Down
0