Skip to content

Commit

Permalink
Fix segfault for empty iterators
Browse files Browse the repository at this point in the history
This commit returns `false` if the first cell in `GetTableInfo` is NULL,
and relies on Python's exception handling of the error instead of
issuing a segfault.
  • Loading branch information
ndmlny-qs committed Sep 15, 2023
1 parent ee0ad21 commit ba7e92b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,10 @@ static bool GetTableInfo(Cursor *cur, Py_ssize_t index, PyObject* param, ParamIn
{
PyObject *cell0 = PySequence_GetItem(param, 0);
Py_XDECREF(cell0);
if (cell0 == NULL)
{
return false;
}
if (PyBytes_Check(cell0) || PyUnicode_Check(cell0))
{
nskip++;
Expand Down

0 comments on commit ba7e92b

Please sign in to comment.