summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-04-11 06:47:43 (GMT)
committerGeorg Brandl <georg@python.org>2006-04-11 06:47:43 (GMT)
commitbbfe4fad361e7190675f28702332ddc377bd8cfd (patch)
tree3c957d97c0802ffd8ab2b6f04018f57f893a11a0 /Modules/posixmodule.c
parentce27a06d37bf512d2e2f142b225c4adad015fe27 (diff)
downloadcpython-bbfe4fad361e7190675f28702332ddc377bd8cfd.zip
cpython-bbfe4fad361e7190675f28702332ddc377bd8cfd.tar.gz
cpython-bbfe4fad361e7190675f28702332ddc377bd8cfd.tar.bz2
Bug #1467952: os.listdir() now correctly raises an error if readdir()
fails with an error condition.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index bc96681..39765b2 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1901,6 +1901,12 @@ posix_listdir(PyObject *self, PyObject *args)
}
Py_DECREF(v);
}
+ if (errno != 0 && d != NULL) {
+ /* readdir() returned NULL and set errno */
+ closedir(dirp);
+ Py_DECREF(d);
+ return posix_error_with_allocated_filename(name);
+ }
closedir(dirp);
PyMem_Free(name);