From e95048e8bb05ed23e7bf281ad445ef4c27b28433 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sat, 3 Dec 2016 13:05:40 -0800 Subject: [PATCH] also do not leak the mode string if creating the file fails --- Modules/posixmodule.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 12f6bc034f..fb435e33e2 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -6909,8 +6909,10 @@ posix_fdopen(PyObject *self, PyObject *args) /* The dummy filename used here must be kept in sync with the value tested against in gzip.GzipFile.__init__() - see issue #13781. */ f = PyFile_FromFile(NULL, "", orgmode, fclose); - if (f == NULL) + if (f == NULL) { + PyMEM_FREE(mode); return NULL; + } Py_BEGIN_ALLOW_THREADS #if !defined(MS_WINDOWS) && defined(HAVE_FCNTL_H) if (mode[0] == 'a') { -- 2.50.0