8000 [2.7] bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized (GH-3958) by orenmn · Pull Request #4333 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[2.7] bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized (GH-3958) #4333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
init commit
  • Loading branch information
orenmn committed Nov 8, 2017
commit ffe9a185bea60899b3c69edacf4d3fd4f21ba450
3 changes: 3 additions & 0 deletions Lib/sqlite3/test/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ def __init__(self, con):
pass
except:
self.fail("should have raised ProgrammingError")
with self.assertRaisesRegexp(sqlite.ProgrammingError,
r'^Base Cursor\.__init__ not called\.$'):
cur.close()

def CheckConnectionConstructorCallCheck(self):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Prevent a crash in ``sqlite3.Cursor.close()`` in case the ``Cursor`` object
is uninitialized. Patch by Oren Milman.
5 changes: 5 additions & 0 deletions Modules/_sqlite/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,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;
}
Expand Down
0