Kaydet (Commit) bbfe4fad authored tarafından Georg Brandl's avatar Georg Brandl

Bug #1467952: os.listdir() now correctly raises an error if readdir()

fails with an error condition.
üst ce27a06d
...@@ -41,6 +41,9 @@ Core and builtins ...@@ -41,6 +41,9 @@ Core and builtins
Extension Modules Extension Modules
----------------- -----------------
- Bug #1467952: os.listdir() now correctly raises an error if readdir()
fails with an error condition.
- Fix bsddb.db.DBError derived exceptions so they can be unpickled. - Fix bsddb.db.DBError derived exceptions so they can be unpickled.
Library Library
......
...@@ -1901,6 +1901,12 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -1901,6 +1901,12 @@ posix_listdir(PyObject *self, PyObject *args)
} }
Py_DECREF(v); 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); closedir(dirp);
PyMem_Free(name); PyMem_Free(name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment