Skip to content

Commit b03a652

Browse files
Ensure reference count of parameters remains the same after call completes!
1 parent 2a87e0f commit b03a652

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Connection.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ static PyObject *Connection_NewCursor(
16431643
PyObject *args, // arguments
16441644
PyObject *keywordArgs) // keyword arguments
16451645
{
1646-
PyObject *createArgs, *result;
1646+
PyObject *createArgs, *result, *arg;
16471647
Py_ssize_t numArgs = 0, i;
16481648

16491649
if (args)
@@ -1653,8 +1653,11 @@ static PyObject *Connection_NewCursor(
16531653
return NULL;
16541654
Py_INCREF(self);
16551655
PyTuple_SET_ITEM(createArgs, 0, (PyObject*) self);
1656-
for (i = 0; i < numArgs; i++)
1657-
PyTuple_SET_ITEM(createArgs, i + 1, PyTuple_GET_ITEM(args, i));
1656+
for (i = 0; i < numArgs; i++) {
1657+
arg = PyTuple_GET_ITEM(args, i);
1658+
Py_INCREF(arg);
1659+
PyTuple_SET_ITEM(createArgs, i + 1, arg);
1660+
}
16581661
result = PyObject_Call( (PyObject*) &g_CursorType, createArgs,
16591662
keywordArgs);
16601663
Py_DECREF(createArgs);

0 commit comments

Comments
 (0)