Skip to content

Commit 91b2638

Browse files
committed
transfer reference of fillvalue; use Py_INCREF/Py_DECREF for fillvalue
1 parent f09bbcb commit 91b2638

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎Modules/itertoolsmodule.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3894,7 +3894,7 @@ zip_longest_new_impl(PyTypeObject *type, PyObject * const *iterables,
38943894

38953895
/* vectorcall passes borrowed references; hold a strong reference before
38963896
PyObject_GetIter() can run arbitrary code. */
3897-
Py_XINCREF(fillvalue);
3897+
Py_INCREF(fillvalue);
38983898

38993899
/* obtain iterators */
39003900
ittuple = PyTuple_New(tuplesize);
@@ -3931,14 +3931,13 @@ zip_longest_new_impl(PyTypeObject *type, PyObject * const *iterables,
39313931
lz->numactive = tuplesize;
39323932
lz->result = result;
39333933
result = NULL;
3934-
lz->fillvalue = Py_NewRef(fillvalue);
3935-
Py_XDECREF(fillvalue);
3934+
lz->fillvalue = fillvalue;
39363935
return (PyObject *)lz;
39373936

39383937
error:
39393938
Py_XDECREF(ittuple);
39403939
Py_XDECREF(result);
3941-
Py_XDECREF(fillvalue);
3940+
Py_DECREF(fillvalue);
39423941
return NULL;
39433942
}
39443943

0 commit comments

Comments
 (0)