Skip to content

Commit 35bf8ea

Browse files
authored
[3.9] bpo-40998: Fix a refleak in create_filter() (pythonGH-23365) (pythonGH-23369)
(cherry picked from commit d1e38d4)
1 parent c53c3f4 commit 35bf8ea

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Python/_warnings.c

+5-2
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)