summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2007-10-14 03:23:09 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2007-10-14 03:23:09 (GMT)
commit6c91378011ff1d39e0f504dedf31b9ecd75c90cf (patch)
tree13404d298dc32181e0cc2fb0c0bca72df331f1df /Modules/posixmodule.c
parent4167ebcfee0449a89c359b8d68530bae92620f45 (diff)
downloadcpython-6c91378011ff1d39e0f504dedf31b9ecd75c90cf.zip
cpython-6c91378011ff1d39e0f504dedf31b9ecd75c90cf.tar.gz
cpython-6c91378011ff1d39e0f504dedf31b9ecd75c90cf.tar.bz2
Fix some more memory leaks (in error conditions) introduced in r58455.
Also fix some indentation.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 53856b4..55af338 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -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, */