summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-06-13 09:15:05 -0700
committerGitHub <noreply@github.com>2020-06-13 09:15:05 -0700
commita8936fa5c09c039ad457dda8bdf733be6cc182e3 (patch)
tree5ef51b788d468dbdd1ca58648b6aba4a9106dc42
parent26db10a431bf5b55340f4427bf015719e384d306 (diff)
downloadcpython-git-a8936fa5c09c039ad457dda8bdf733be6cc182e3.tar.gz
bpo-40957: Fix refleak in _Py_fopen_obj() (GH-20827)
Signed-off-by: Christian Heimes <christian@python.org> (cherry picked from commit 9672912e8f90374fd31b37ca0fb7cefbc6f4c555) Co-authored-by: Christian Heimes <christian@python.org>
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-06-12-12-21-54.bpo-40957.Z8n6I6.rst1
-rw-r--r--Python/fileutils.c1
2 files changed, 2 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-06-12-12-21-54.bpo-40957.Z8n6I6.rst b/Misc/NEWS.d/next/Core and Builtins/2020-06-12-12-21-54.bpo-40957.Z8n6I6.rst
new file mode 100644
index 0000000000..f99c374f94
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-06-12-12-21-54.bpo-40957.Z8n6I6.rst
@@ -0,0 +1 @@
+Fix refleak in _Py_fopen_obj() when PySys_Audit() fails
diff --git a/Python/fileutils.c b/Python/fileutils.c
index e79e732d1f..1021ddb588 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -1461,6 +1461,7 @@ _Py_fopen_obj(PyObject *path, const char *mode)
path_bytes = PyBytes_AS_STRING(bytes);
if (PySys_Audit("open", "Osi", path, mode, 0) < 0) {
+ Py_DECREF(bytes);
return NULL;
}