mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
bpo-44304: Fix crash in the sqlite3 module when the GC clears Statement objects (GH-26545)
(cherry picked from commit fa106a685c
)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
parent
4642caf232
commit
ad2f3b74b5
3 changed files with 23 additions and 7 deletions
|
@ -397,6 +397,10 @@ stmt_dealloc(pysqlite_Statement *self)
|
|||
if (self->in_weakreflist != NULL) {
|
||||
PyObject_ClearWeakRefs((PyObject*)self);
|
||||
}
|
||||
if (self->st) {
|
||||
sqlite3_finalize(self->st);
|
||||
self->st = 0;
|
||||
}
|
||||
tp->tp_clear((PyObject *)self);
|
||||
tp->tp_free(self);
|
||||
Py_DECREF(tp);
|
||||
|
@ -405,13 +409,6 @@ stmt_dealloc(pysqlite_Statement *self)
|
|||
static int
|
||||
stmt_clear(pysqlite_Statement *self)
|
||||
{
|
||||
if (self->st) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
sqlite3_finalize(self->st);
|
||||
Py_END_ALLOW_THREADS
|
||||
self->st = 0;
|
||||
}
|
||||
|
||||
Py_CLEAR(self->sql);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue