]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix the memory leak introduced in r58455. The buffer reference
authorAlexandre Vassalotti <alexandre@peadrop.com>
Sun, 14 Oct 2007 02:54:41 +0000 (02:54 +0000)
committerAlexandre Vassalotti <alexandre@peadrop.com>
Sun, 14 Oct 2007 02:54:41 +0000 (02:54 +0000)
returned by 'et' need to be freed after usage.

Modules/posixmodule.c

index 2fe2b6396cac67c8d28ec6c8c96d354e7881e5ee..53856b4cd9589de5c64c4eb9310e2e7dc97faffc 100644 (file)
@@ -2150,8 +2150,10 @@ posix_listdir(PyObject *self, PyObject *args)
         namebuf[len++] = SEP;
     strcpy(namebuf + len, "*.*");
 
-       if ((d = PyList_New(0)) == NULL)
+       if ((d = PyList_New(0)) == NULL) {
+        PyMem_Free(name);
         return NULL;
+    }
 
     rc = DosFindFirst(namebuf,         /* Wildcard Pattern to Match */
                       &hdir,           /* Handle to Use While Search Directory */
@@ -2192,6 +2194,7 @@ posix_listdir(PyObject *self, PyObject *args)
         } while (DosFindNext(hdir, &ep, sizeof(ep), &srchcnt) == NO_ERROR && srchcnt > 0);
     }
 
+    PyMem_Free(name);
     return d;
 #else