summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorOren Milman <orenmn@gmail.com>2017-11-07 00:09:49 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-11-07 00:09:49 (GMT)
commitedb13ae48c17210fa4b2d40a6833ca09db5c121b (patch)
treeb794f824b29d8c6e82add09c00dc24985b3fe01e /Modules
parente56ab746a965277ffcc4396d8a0902b6e072d049 (diff)
downloadcpython-edb13ae48c17210fa4b2d40a6833ca09db5c121b.zip
cpython-edb13ae48c17210fa4b2d40a6833ca09db5c121b.tar.gz
cpython-edb13ae48c17210fa4b2d40a6833ca09db5c121b.tar.bz2
bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized (#3958)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_sqlite/cursor.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index f7a34c1..4ecb5b4 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;
}