diff options
author | Just van Rossum <just@letterror.com> | 2003-03-03 19:07:13 (GMT) |
---|---|---|
committer | Just van Rossum <just@letterror.com> | 2003-03-03 19:07:13 (GMT) |
commit | 2fe07fda2d2d6f88e99a83ed7c625e80489a6f4d (patch) | |
tree | b566ac034adee2eada39abfc15be22c7479a0600 /Modules/posixmodule.c | |
parent | a2eaf31727034f8cff9835f4b2140007f450ccec (diff) | |
download | cpython-2fe07fda2d2d6f88e99a83ed7c625e80489a6f4d.zip cpython-2fe07fda2d2d6f88e99a83ed7c625e80489a6f4d.tar.gz cpython-2fe07fda2d2d6f88e99a83ed7c625e80489a6f4d.tar.bz2 |
plugged leak noted by nnorwitz: the 'et' format returns allocated memory
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index d9033f6..cc922725 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1771,7 +1771,7 @@ posix_listdir(PyObject *self, PyObject *args) return d; #else - char *name; + char *name = NULL; PyObject *d, *v; DIR *dirp; struct dirent *ep; @@ -1784,10 +1784,11 @@ posix_listdir(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "et:listdir", Py_FileSystemDefaultEncoding, &name)) return NULL; if ((dirp = opendir(name)) == NULL) { - return posix_error_with_filename(name); + return posix_error_with_allocated_filename(name); } if ((d = PyList_New(0)) == NULL) { closedir(dirp); + PyMem_Free(name); return NULL; } while ((ep = readdir(dirp)) != NULL) { @@ -1826,6 +1827,7 @@ posix_listdir(PyObject *self, PyObject *args) Py_DECREF(v); } closedir(dirp); + PyMem_Free(name); return d; |