summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorOren Milman <orenmn@gmail.com>2017-10-10 19:27:46 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-10-10 19:27:46 (GMT)
commit93c5a5df8ea118f6e4a153a7c8cccd65a5ff8bff (patch)
tree6dd035ae96ed7995a747bed1fe95ebeb6ffb1b34 /Modules
parenta997c7b434631f51e00191acea2ba6097691e859 (diff)
downloadcpython-93c5a5df8ea118f6e4a153a7c8cccd65a5ff8bff.zip
cpython-93c5a5df8ea118f6e4a153a7c8cccd65a5ff8bff.tar.gz
cpython-93c5a5df8ea118f6e4a153a7c8cccd65a5ff8bff.tar.bz2
bpo-31740: Prevent refleaks when sqlite3.Connection.__init__() is called more than once (GH-3944)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_sqlite/connection.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index 2759116..70e56aa 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -97,15 +97,15 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
self->begin_statement = NULL;
- self->statement_cache = NULL;
- self->statements = NULL;
- self->cursors = NULL;
+ Py_CLEAR(self->statement_cache);
+ Py_CLEAR(self->statements);
+ Py_CLEAR(self->cursors);
Py_INCREF(Py_None);
- self->row_factory = Py_None;
+ Py_XSETREF(self->row_factory, Py_None);
Py_INCREF(&PyUnicode_Type);
- self->text_factory = (PyObject*)&PyUnicode_Type;
+ Py_XSETREF(self->text_factory, (PyObject*)&PyUnicode_Type);
#ifdef SQLITE_OPEN_URI
Py_BEGIN_ALLOW_THREADS
@@ -137,7 +137,7 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
} else {
Py_INCREF(isolation_level);
}
- self->isolation_level = NULL;
+ Py_CLEAR(self->isolation_level);
if (pysqlite_connection_set_isolation_level(self, isolation_level) < 0) {
Py_DECREF(isolation_level);
return -1;
@@ -177,12 +177,12 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
}
self->check_same_thread = check_same_thread;
- self->function_pinboard = PyDict_New();
+ Py_XSETREF(self->function_pinboard, PyDict_New());
if (!self->function_pinboard) {
return -1;
}
- self->collations = PyDict_New();
+ Py_XSETREF(self->collations, PyDict_New());
if (!self->collations) {
return -1;
}