]> granicus.if.org Git - python/commitdiff
also do not leak the mode string if creating the file fails
authorBenjamin Peterson <benjamin@python.org>
Sat, 3 Dec 2016 21:05:40 +0000 (13:05 -0800)
committerBenjamin Peterson <benjamin@python.org>
Sat, 3 Dec 2016 21:05:40 +0000 (13:05 -0800)
Modules/posixmodule.c

index 12f6bc034f636992abc88d58c66ac8cb695aebef..fb435e33e2d87e23f64e14ad41efb0138ecb3013 100644 (file)
@@ -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, "<fdopen>", 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') {