mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-31770: Prevent a crash and refleaks when calling sqlite3.Cursor.__init__() more than once (GH-3968) (#4301)
(cherry picked from commit e56ab746a9
)
This commit is contained in:
parent
a6ffec2e88
commit
9684cf69e3
3 changed files with 27 additions and 8 deletions
|
@ -39,21 +39,20 @@ static int pysqlite_cursor_init(pysqlite_Cursor* self, PyObject* args, PyObject*
|
|||
}
|
||||
|
||||
Py_INCREF(connection);
|
||||
self->connection = connection;
|
||||
self->statement = NULL;
|
||||
self->next_row = NULL;
|
||||
self->in_weakreflist = NULL;
|
||||
Py_XSETREF(self->connection, connection);
|
||||
Py_CLEAR(self->statement);
|
||||
Py_CLEAR(self->next_row);
|
||||
|
||||
self->row_cast_map = PyList_New(0);
|
||||
Py_XSETREF(self->row_cast_map, PyList_New(0));
|
||||
if (!self->row_cast_map) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
self->description = Py_None;
|
||||
Py_XSETREF(self->description, Py_None);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
self->lastrowid= Py_None;
|
||||
Py_XSETREF(self->lastrowid, Py_None);
|
||||
|
||||
self->arraysize = 1;
|
||||
self->closed = 0;
|
||||
|
@ -62,7 +61,7 @@ static int pysqlite_cursor_init(pysqlite_Cursor* self, PyObject* args, PyObject*
|
|||
self->rowcount = -1L;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
self->row_factory = Py_None;
|
||||
Py_XSETREF(self->row_factory, Py_None);
|
||||
|
||||
if (!pysqlite_check_thread(self->connection)) {
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue