]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40998: Fix a refleak in create_filter() (GH-23365)
authorVictor Stinner <vstinner@python.org>
Wed, 18 Nov 2020 14:57:10 +0000 (15:57 +0100)
committerGitHub <noreply@github.com>
Wed, 18 Nov 2020 14:57:10 +0000 (06:57 -0800)
Python/_warnings.c

index 8d33fbe0f878b8a709ba6d662893fe6e134467b3..313420c63148f43e1cb749a647060e9104dbd169 100644 (file)
@@ -69,12 +69,14 @@ create_filter(PyObject *category, _Py_Identifier *id, const char *modname)
             return NULL;
         }
     } else {
-        modname_obj = Py_None;
+        modname_obj = Py_NewRef(Py_None);
     }
 
     /* This assumes the line number is zero for now. */
-    return PyTuple_Pack(5, action_str, Py_None,
-                        category, modname_obj, _PyLong_GetZero());
+    PyObject *filter = PyTuple_Pack(5, action_str, Py_None,
+                                    category, modname_obj, _PyLong_GetZero());
+    Py_DECREF(modname_obj);
+    return filter;
 }
 #endif