summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2020-11-18 17:45:29 (GMT)
committerGitHub <noreply@github.com>2020-11-18 17:45:29 (GMT)
commit35bf8ea7bef7151a420a67638e88d6a1fd81d1a0 (patch)
tree5093360b35ca8889e0697f29744254012d69ed82 /Python
parentc53c3f400050a7edc92ccb7285a6d7eeb4c37fd2 (diff)
downloadcpython-35bf8ea7bef7151a420a67638e88d6a1fd81d1a0.zip
cpython-35bf8ea7bef7151a420a67638e88d6a1fd81d1a0.tar.gz
cpython-35bf8ea7bef7151a420a67638e88d6a1fd81d1a0.tar.bz2
[3.9] bpo-40998: Fix a refleak in create_filter() (GH-23365) (GH-23369)
(cherry picked from commit d1e38d4023aa29e7ed64d4f8eb9c1e4a3c86a2e5)
Diffstat (limited to 'Python')
-rw-r--r--Python/_warnings.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 4d65bb3..91a78fe 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -69,11 +69,14 @@ create_filter(PyObject *category, _Py_Identifier *id, const char *modname)
}
} else {
modname_obj = Py_None;
+ Py_INCREF(modname_obj);
}
/* This assumes the line number is zero for now. */
- return PyTuple_Pack(5, action_str, Py_None,
- category, modname_obj, _PyLong_Zero);
+ PyObject *filter = PyTuple_Pack(5, action_str, Py_None,
+ category, modname_obj, _PyLong_Zero);
+ Py_DECREF(modname_obj);
+ return filter;
}
#endif