Kaydet (Commit) edb13ae4 authored tarafından Oren Milman's avatar Oren Milman Kaydeden (comit) Victor Stinner

bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object…

bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized (#3958)
üst e56ab746
......@@ -190,6 +190,9 @@ class RegressionTests(unittest.TestCase):
cur = Cursor(con)
with self.assertRaises(sqlite.ProgrammingError):
cur.execute("select 4+5").fetchall()
with self.assertRaisesRegex(sqlite.ProgrammingError,
r'^Base Cursor\.__init__ not called\.$'):
cur.close()
def CheckStrSubclass(self):
"""
......
Prevent a crash in ``sqlite3.Cursor.close()`` in case the ``Cursor`` object is
uninitialized. Patch by Oren Milman.
......@@ -889,6 +889,11 @@ PyObject* pysqlite_noop(pysqlite_Connection* self, PyObject* args)
PyObject* pysqlite_cursor_close(pysqlite_Cursor* self, PyObject* args)
{
if (!self->connection) {
PyErr_SetString(pysqlite_ProgrammingError,
"Base Cursor.__init__ not called.");
return NULL;
}
if (!pysqlite_check_thread(self->connection) || !pysqlite_check_connection(self->connection)) {
return NULL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment