]> granicus.if.org Git - python/commitdiff
Fix some more memory leaks (in error conditions) introduced in r58455.
authorNeal Norwitz <nnorwitz@gmail.com>
Sun, 14 Oct 2007 03:23:09 +0000 (03:23 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sun, 14 Oct 2007 03:23:09 +0000 (03:23 +0000)
Also fix some indentation.

Modules/posixmodule.c

index 53856b4cd9589de5c64c4eb9310e2e7dc97faffc..55af338e0a065484e11ca59afcf2b57a13ea970f 100644 (file)
@@ -2139,7 +2139,8 @@ posix_listdir(PyObject *self, PyObject *args)
                           Py_FileSystemDefaultEncoding, &name, &len))
         return NULL;
     if (len >= MAX_PATH) {
-               PyErr_SetString(PyExc_ValueError, "path too long");
+        PyMem_Free(name);
+        PyErr_SetString(PyExc_ValueError, "path too long");
         return NULL;
     }
     strcpy(namebuf, name);
@@ -2150,7 +2151,7 @@ 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;
     }
@@ -2164,7 +2165,7 @@ posix_listdir(PyObject *self, PyObject *args)
 
     if (rc != NO_ERROR) {
         errno = ENOENT;
-        return posix_error_with_filename(name);
+        return posix_error_with_allocated_filename(name);
     }
 
     if (srchcnt > 0) { /* If Directory is NOT Totally Empty, */