Skip to content

Commit 999913b

Browse files
Ensure reference count of parameters remains the same after call completes!
1 parent 2e240bc commit 999913b

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
@@ -1003,7 +1003,7 @@ static PyObject *Connection_Rollback(udt_Connection *self, PyObject *args)
10031003
static PyObject *Connection_NewCursor(udt_Connection *self, PyObject *args,
10041004
PyObject *keywordArgs)
10051005
{
1006-
PyObject *createArgs, *result;
1006+
PyObject *createArgs, *result, *arg;
10071007
Py_ssize_t numArgs = 0, i;
10081008

10091009
if (args)
@@ -1013,8 +1013,11 @@ static PyObject *Connection_NewCursor(udt_Connection *self, PyObject *args,
10131013
return NULL;
10141014
Py_INCREF(self);
10151015
PyTuple_SET_ITEM(createArgs, 0, (PyObject*) self);
1016-
for (i = 0; i < numArgs; i++)
1017-
PyTuple_SET_ITEM(createArgs, i + 1, PyTuple_GET_ITEM(args, i));
1016+
for (i = 0; i < numArgs; i++) {
1017+
arg = PyTuple_GET_ITEM(args, i);
1018+
Py_INCREF(arg);
1019+
PyTuple_SET_ITEM(createArgs, i + 1, arg);
1020+
}
10181021
result = PyObject_Call( (PyObject*) &g_CursorType, createArgs,
10191022
keywordArgs);
10201023
Py_DECREF(createArgs);

0 commit comments

Comments
 (0)