diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2017-11-07 00:45:19 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2017-11-07 00:45:19 (GMT) |
commit | b0331c94c2a210d50e43d99b249ec83ee165e70c (patch) | |
tree | fd7cccab9e2abd97d0c076e11ce8413977b7fad8 /Modules/_sqlite/cursor.c | |
parent | 9684cf69e32ae442c7be54521073ac78557f3bbf (diff) | |
download | cpython-b0331c94c2a210d50e43d99b249ec83ee165e70c.zip cpython-b0331c94c2a210d50e43d99b249ec83ee165e70c.tar.gz cpython-b0331c94c2a210d50e43d99b249ec83ee165e70c.tar.bz2 |
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/cursor.c')
-rw-r--r-- | Modules/_sqlite/cursor.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index b6257a0..8237340 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; } |