-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
gh-149738: Fix segmentation fault bug in sqllite3 #149754
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
base: main
Are you sure you want to change the base?
Changes from all commits
388090c
3da9d0e
6f4faa3
cdee382
a0d272a
5c64a63
4d75cf9
20ab789
b36aa69
0d6c3ae
6920132
7cce0ad
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 @@ | ||
| :mod:`sqlite3`: Disallow removing ``row_factory`` and ``text_factory`` attributes | ||
|
Member
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. Pleas update the docs of salite3.rst as well to indicate this change using a versionchanged directive. |
||
| of a connection to prevent a crash on a query. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -557,6 +557,43 @@ pysqlite_connection_cursor_impl(pysqlite_Connection *self, PyObject *factory) | |
| return cursor; | ||
| } | ||
|
|
||
| static PyObject * | ||
| connection_get_row_factory(pysqlite_Connection *self, void *closure) | ||
|
Member
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. Those getsets must be using a critical section as well. |
||
| { | ||
| return Py_NewRef(self->row_factory); | ||
| } | ||
|
|
||
| static int | ||
| connection_set_row_factory(pysqlite_Connection *self, PyObject *value, void *closure) | ||
| { | ||
| if (value == NULL) { | ||
| PyErr_SetString(PyExc_AttributeError, | ||
| "cannot delete row_factory attribute"); | ||
| return -1; | ||
| } | ||
| Py_XSETREF(self->row_factory, Py_NewRef(value)); | ||
| return 0; | ||
| } | ||
|
|
||
| static PyObject * | ||
| connection_get_text_factory(pysqlite_Connection *self, void *closure) | ||
| { | ||
| return Py_NewRef(self->text_factory); | ||
| } | ||
|
|
||
| static int | ||
| connection_set_text_factory(pysqlite_Connection *self, PyObject *value, void *closure) | ||
|
Member
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. The signature is incorrect, it must be |
||
| { | ||
| if (value == NULL) { | ||
| PyErr_SetString(PyExc_AttributeError, | ||
| "cannot delete text_factory attribute"); | ||
| return -1; | ||
| } | ||
| Py_XSETREF(self->text_factory, Py_NewRef(value)); | ||
| return 0; | ||
| } | ||
|
|
||
|
|
||
| /*[clinic input] | ||
| _sqlite3.Connection.blobopen as blobopen | ||
|
|
||
|
|
@@ -2620,6 +2657,10 @@ static PyGetSetDef connection_getset[] = { | |
| {"in_transaction", pysqlite_connection_get_in_transaction, NULL}, | ||
| {"autocommit", get_autocommit, set_autocommit}, | ||
| {"__text_signature__", get_sig, NULL}, | ||
| {"row_factory", (getter)connection_get_row_factory, | ||
| (setter)connection_set_row_factory}, | ||
| {"text_factory", (getter)connection_get_text_factory, | ||
| (setter)connection_set_text_factory}, | ||
| {NULL} | ||
| }; | ||
|
|
||
|
|
@@ -2667,8 +2708,6 @@ static struct PyMemberDef connection_members[] = | |
| {"InternalError", _Py_T_OBJECT, offsetof(pysqlite_Connection, InternalError), Py_READONLY}, | ||
| {"ProgrammingError", _Py_T_OBJECT, offsetof(pysqlite_Connection, ProgrammingError), Py_READONLY}, | ||
| {"NotSupportedError", _Py_T_OBJECT, offsetof(pysqlite_Connection, NotSupportedError), Py_READONLY}, | ||
| {"row_factory", _Py_T_OBJECT, offsetof(pysqlite_Connection, row_factory)}, | ||
| {"text_factory", _Py_T_OBJECT, offsetof(pysqlite_Connection, text_factory)}, | ||
| {NULL} | ||
| }; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.