From b0331c94c2a210d50e43d99b249ec83ee165e70c Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Mon, 6 Nov 2017 16:45:19 -0800 Subject: bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized (GH-3958) (#4303) (cherry picked from commit edb13ae48c17210fa4b2d40a6833ca09db5c121b) --- Modules/_sqlite/cursor.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Modules/_sqlite/cursor.c') diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index b6257a0b9d..8237340947 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -916,6 +916,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; } -- cgit v1.2.1