From edb13ae48c17210fa4b2d40a6833ca09db5c121b Mon Sep 17 00:00:00 2001 From: Oren Milman Date: Tue, 7 Nov 2017 02:09:49 +0200 Subject: bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized (#3958) --- 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 f7a34c10c2..4ecb5b4b92 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -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; } -- cgit v1.2.1