Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c2b09e

Browse files
committed
be extra careful with a borrowed reference when the GIL could be released (closes #8578)
1 parent 2e3a38a commit 5c2b09e

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Modules/_sqlite/connection.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,13 @@ void pysqlite_do_all_statements(pysqlite_Connection* self, int action, int reset
200200
weakref = PyList_GetItem(self->statements, i);
201201
statement = PyWeakref_GetObject(weakref);
202202
if (statement != Py_None) {
203+
Py_INCREF(statement);
203204
if (action == ACTION_RESET) {
204205
(void)pysqlite_statement_reset((pysqlite_Statement*)statement);
205206
} else {
206207
(void)pysqlite_statement_finalize((pysqlite_Statement*)statement);
207208
}
209+
Py_DECREF(statement);
208210
}
209211
}
210212

0 commit comments

Comments
 (0)