Skip to content

Commit d1e38d4

Browse files
authored
bpo-40998: Fix a refleak in create_filter() (GH-23365)
1 parent 8fba952 commit d1e38d4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Python/_warnings.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ create_filter(PyObject *category, _Py_Identifier *id, const char *modname)
6969
return NULL;
7070
}
7171
} else {
72-
modname_obj = Py_None;
72+
modname_obj = Py_NewRef(Py_None);
7373
}
7474

7575
/* This assumes the line number is zero for now. */
76-
return PyTuple_Pack(5, action_str, Py_None,
77-
category, modname_obj, _PyLong_GetZero());
76+
PyObject *filter = PyTuple_Pack(5, action_str, Py_None,
77+
category, modname_obj, _PyLong_GetZero());
78+
Py_DECREF(modname_obj);
79+
return filter;
7880
}
7981
#endif
8082

0 commit comments

Comments
 (0)