From 394dc0db878c08d003772de163a57ac12046d865 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Tue, 3 Mar 2020 01:13:10 +0000 Subject: [3.8] bpo-39831: Fix a reference leak in PyErr_WarnEx(). (GH-18750) (GH-18761) (cherry picked from commit 2d2f855) Co-authored-by: Serhiy Storchaka --- Python/_warnings.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Python/_warnings.c b/Python/_warnings.c index e02d283..87269dd 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -856,11 +856,11 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno, int rc; if (PyErr_Occurred()) { - return 0; + goto handle_error; } *registry = PyDict_New(); if (*registry == NULL) - return 0; + goto handle_error; rc = _PyDict_SetItemId(globals, &PyId___warningregistry__, *registry); if (rc < 0) @@ -890,6 +890,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; } -- cgit v0.12