[Python-checkins] [3.7] bpo-39831: Fix a reference leak in PyErr_WarnEx(). (GH-18750). (GH-18760)

Pablo Galindo webhook-mailer at python.org
Mon Mar 2 20:13:28 EST 2020


https://github.com/python/cpython/commit/499c926fbeafa7e4c15d925fea27fe8a65cc3b25
commit: 499c926fbeafa7e4c15d925fea27fe8a65cc3b25
branch: 3.7
author: Pablo Galindo <Pablogsal at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-03-03T01:13:24Z
summary:

[3.7] bpo-39831: Fix a reference leak in PyErr_WarnEx(). (GH-18750). (GH-18760)

(cherry picked from commit 2d2f85517f8216146a2f888d1ad4d765b3be2339)

Co-authored-by: Serhiy Storchaka <storchaka at gmail.com>

files:
M Python/_warnings.c

diff --git a/Python/_warnings.c b/Python/_warnings.c
index e86a582a01cf4..1a2035eb250d5 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -710,7 +710,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
 
         *registry = PyDict_New();
         if (*registry == NULL)
-            return 0;
+            goto handle_error;
 
          rc = PyDict_SetItemString(globals, "__warningregistry__", *registry);
          if (rc < 0)
@@ -802,6 +802,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
        dangling reference. */
     Py_XDECREF(*registry);
     Py_XDECREF(*module);
+    Py_XDECREF(*filename);
     return 0;
 }
 



More information about the Python-checkins mailing list