summaryrefslogtreecommitdiffstats
path: root/Python/_warnings.c
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-03-03 01:13:10 (GMT)
committerGitHub <noreply@github.com>2020-03-03 01:13:10 (GMT)
commit394dc0db878c08d003772de163a57ac12046d865 (patch)
tree0f7e464fbe56dfeb9a14392795fe45da85fccd57 /Python/_warnings.c
parent0d20364b132014eec609b900997c34779a4d548c (diff)
downloadcpython-394dc0db878c08d003772de163a57ac12046d865.zip
cpython-394dc0db878c08d003772de163a57ac12046d865.tar.gz
cpython-394dc0db878c08d003772de163a57ac12046d865.tar.bz2
[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 <storchaka@gmail.com>
Diffstat (limited to 'Python/_warnings.c')
-rw-r--r--Python/_warnings.c5
1 files 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;
}