summaryrefslogtreecommitdiff
path: root/Modules/_sqlite
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2017-11-06 16:45:19 -0800
committerVictor Stinner <victor.stinner@gmail.com>2017-11-06 16:45:19 -0800
commitb0331c94c2a210d50e43d99b249ec83ee165e70c (patch)
treefd7cccab9e2abd97d0c076e11ce8413977b7fad8 /Modules/_sqlite
parent9684cf69e32ae442c7be54521073ac78557f3bbf (diff)
downloadcpython-git-b0331c94c2a210d50e43d99b249ec83ee165e70c.tar.gz
bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized (GH-3958) (#4303)
(cherry picked from commit edb13ae48c17210fa4b2d40a6833ca09db5c121b)
Diffstat (limited to 'Modules/_sqlite')
-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 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;
}