Skip to content

Commit fa71a0f

Browse files
vstinnertiran
authored andcommitted
[3.9] bpo-40998: Fix a refleak in create_filter() (GH-23365). (cherry picked from commit d1e38d4)
1 parent 802ff7c commit fa71a0f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Python/_warnings.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,14 @@ create_filter(PyObject *category, _Py_Identifier *id, const char *modname)
6969
}
7070
} else {
7171
modname_obj = Py_None;
72+
Py_INCREF(modname_obj);
7273
}
7374

7475
/* This assumes the line number is zero for now. */
75-
return PyTuple_Pack(5, action_str, Py_None,
76-
category, modname_obj, _PyLong_Zero);
76+
PyObject *filter = PyTuple_Pack(5, action_str, Py_None,
77+
category, modname_obj, _PyLong_Zero);
78+
Py_DECREF(modname_obj);
79+
return filter;
7780
}
7881
#endif
7982

0 commit comments

Comments
 (0)