diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2021-06-05 02:50:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-05 02:50:39 (GMT) |
commit | fa106a685c1f199aca5be5c2d0277a14cc9057bd (patch) | |
tree | bfca3ae142a9bff2241102fef5b3b459701dbd67 /Modules/_sqlite | |
parent | f171877ebe276749f31386baed5841ce37cbee2e (diff) | |
download | cpython-fa106a685c1f199aca5be5c2d0277a14cc9057bd.zip cpython-fa106a685c1f199aca5be5c2d0277a14cc9057bd.tar.gz cpython-fa106a685c1f199aca5be5c2d0277a14cc9057bd.tar.bz2 |
bpo-44304: Fix crash in the sqlite3 module when the GC clears Statement objects (GH-26545)
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r-- | Modules/_sqlite/statement.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c index c86645a..c9dd882 100644 --- a/Modules/_sqlite/statement.c +++ b/Modules/_sqlite/statement.c @@ -403,6 +403,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); @@ -411,13 +415,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; } |