]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.9] bpo-40998: Fix a refleak in create_filter() (GH-23365) (GH-23369)
authorChristian Heimes <christian@python.org>
Wed, 18 Nov 2020 17:45:29 +0000 (18:45 +0100)
committerGitHub <noreply@github.com>
Wed, 18 Nov 2020 17:45:29 +0000 (09:45 -0800)
(cherry picked from commit d1e38d4023aa29e7ed64d4f8eb9c1e4a3c86a2e5)

Python/_warnings.c

index 4d65bb30c8e5cdb2b84a951e9718a1c869ba6cc6..91a78fe72b3bc504765ca7e2ae006615e6ff0efe 100644 (file)
@@ -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