diff options
author | Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp> | 2009-05-04 05:56:46 (GMT) |
---|---|---|
committer | Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp> | 2009-05-04 05:56:46 (GMT) |
commit | bbb9be72110c7f4a8756eb7abbe8385fafddea1c (patch) | |
tree | c61e5495e5e8abd583f9f4df2b84f5be476ff707 /Modules/posixmodule.c | |
parent | 73e8e5f1c729ef8492dd1cd18b421ec998269c0a (diff) | |
download | cpython-bbb9be72110c7f4a8756eb7abbe8385fafddea1c.zip cpython-bbb9be72110c7f4a8756eb7abbe8385fafddea1c.tar.gz cpython-bbb9be72110c7f4a8756eb7abbe8385fafddea1c.tar.bz2 |
Merged revisions 72273 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r72273 | hirokazu.yamamoto | 2009-05-04 14:28:39 +0900 | 1 line
Issue #5913: os.listdir() should fail for empty path on windows.
........
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 7b8c057..0575be2 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -2183,7 +2183,6 @@ posix_listdir(PyObject *self, PyObject *args) if (PyArg_ParseTuple(args, "U:listdir", &po)) { WIN32_FIND_DATAW wFileData; Py_UNICODE *wnamebuf; - Py_UNICODE wch; /* Overallocate for \\*.*\0 */ len = PyUnicode_GET_SIZE(po); wnamebuf = malloc((len + 5) * sizeof(wchar_t)); @@ -2192,10 +2191,12 @@ posix_listdir(PyObject *self, PyObject *args) return NULL; } wcscpy(wnamebuf, PyUnicode_AS_UNICODE(po)); - wch = len > 0 ? wnamebuf[len-1] : '\0'; - if (wch != L'/' && wch != L'\\' && wch != L':') - wnamebuf[len++] = L'\\'; - wcscpy(wnamebuf + len, L"*.*"); + if (len > 0) { + Py_UNICODE wch = wnamebuf[len-1]; + if (wch != L'/' && wch != L'\\' && wch != L':') + wnamebuf[len++] = L'\\'; + wcscpy(wnamebuf + len, L"*.*"); + } if ((d = PyList_New(0)) == NULL) { free(wnamebuf); return NULL; @@ -2266,8 +2267,8 @@ posix_listdir(PyObject *self, PyObject *args) char ch = namebuf[len-1]; if (ch != SEP && ch != ALTSEP && ch != ':') namebuf[len++] = '/'; + strcpy(namebuf + len, "*.*"); } - strcpy(namebuf + len, "*.*"); if ((d = PyList_New(0)) == NULL) return NULL; |