From: Benjamin Peterson Date: Sat, 3 Dec 2016 21:05:40 +0000 (-0800) Subject: also do not leak the mode string if creating the file fails X-Git-Tag: v2.7.13~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e95048e8bb05ed23e7bf281ad445ef4c27b28433;p=python also do not leak the mode string if creating the file fails --- 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') {