Skip to content

Commit 5e828a6

Browse files
serhiy-storchakapablogsal
authored andcommitted
[3.7] bpo-39831: Fix a reference leak in PyErr_WarnEx(). (GH-18750).
(cherry picked from commit 2d2f855) Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent 8a5f7ad commit 5e828a6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Python/_warnings.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
710710

711711
*registry = PyDict_New();
712712
if (*registry == NULL)
713-
return 0;
713+
goto handle_error;
714714

715715
rc = PyDict_SetItemString(globals, "__warningregistry__", *registry);
716716
if (rc < 0)
@@ -802,6 +802,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
802802
dangling reference. */
803803
Py_XDECREF(*registry);
804804
Py_XDECREF(*module);
805+
Py_XDECREF(*filename);
805806
return 0;
806807
}
807808

0 commit comments

Comments
 (0)