]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40957: Fix refleak in _Py_fopen_obj() (GH-20827)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 13 Jun 2020 16:15:05 +0000 (09:15 -0700)
committerGitHub <noreply@github.com>
Sat, 13 Jun 2020 16:15:05 +0000 (09:15 -0700)
Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit 9672912e8f90374fd31b37ca0fb7cefbc6f4c555)

Co-authored-by: Christian Heimes <christian@python.org>
Misc/NEWS.d/next/Core and Builtins/2020-06-12-12-21-54.bpo-40957.Z8n6I6.rst [new file with mode: 0644]
Python/fileutils.c

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 (file)
index 0000000..f99c374
--- /dev/null
@@ -0,0 +1 @@
+Fix refleak in _Py_fopen_obj() when PySys_Audit() fails
index e79e732d1f55b731186a31370d4e6bad7b371327..1021ddb58853e0aa993327dd6c23b4cbca1c9572 100644 (file)
@@ -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;
     }