-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized #3958
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
bpo-31764: Prevent a crash in sqlite3.Cursor.close() in case the Cursor object is uninitialized #3958
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use double backticks (``). I tried to explain why single backticks shouldn't be used at #3925 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not familiar with Sphinx, but i trust you are :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I wasn't aware of that example in the devguide. I will update it, thanks! |
||
uninitialized. Patch by Oren Milman. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -890,6 +890,11 @@ PyObject* pysqlite_noop(pysqlite_Connection* self, PyObject* args) | |
|
||
PyObject* pysqlite_cursor_close(pysqlite_Cursor* self, PyObject* args) | ||
{ | ||
if (self->connection == NULL) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style nit: I think |
||
PyErr_SetString(pysqlite_ProgrammingError, | ||
"Base Cursor.__init__ not called."); | ||
return NULL; | ||
} | ||
if (!pysqlite_check_thread(self->connection) || !pysqlite_check_connection(self->connection)) { | ||
return NULL; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ProgrammingError
is raised by a lot of things so I wonder if we should add a test for the exception message to make it more future-proof.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right. Should i also change the
assertRaises()
that was already inCheckCursorConstructorCallCheck()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say let's do it only for new additions to the test.