mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #27861: Fixed a crash in sqlite3.Connection.cursor() when a factory
creates not a cursor. Patch by Xiang Zhang.
This commit is contained in:
parent
5de141f157
commit
ef113cd4cc
4 changed files with 35 additions and 9 deletions
|
@ -300,7 +300,7 @@ error:
|
|||
|
||||
PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, PyObject* kwargs)
|
||||
{
|
||||
static char *kwlist[] = {"factory", NULL, NULL};
|
||||
static char *kwlist[] = {"factory", NULL};
|
||||
PyObject* factory = NULL;
|
||||
PyObject* cursor;
|
||||
|
||||
|
@ -317,7 +317,16 @@ PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args,
|
|||
factory = (PyObject*)&pysqlite_CursorType;
|
||||
}
|
||||
|
||||
cursor = PyObject_CallFunction(factory, "O", self);
|
||||
cursor = PyObject_CallFunctionObjArgs(factory, (PyObject *)self, NULL);
|
||||
if (cursor == NULL)
|
||||
return NULL;
|
||||
if (!PyObject_TypeCheck(cursor, &pysqlite_CursorType)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"factory must return a cursor, not %.100s",
|
||||
Py_TYPE(cursor)->tp_name);
|
||||
Py_DECREF(cursor);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_pysqlite_drop_unused_cursor_references(self);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue