We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 398b9f6 commit 94b866aCopy full SHA for 94b866a
Modules/posixmodule.c
@@ -980,14 +980,15 @@ posix_listdir(PyObject *self, PyObject *args)
980
char namebuf[MAX_PATH*2+5];
981
char *bufptr = namebuf;
982
int len = sizeof(namebuf)/sizeof(namebuf[0]);
983
- char ch;
984
985
if (!PyArg_ParseTuple(args, "et#:listdir",
986
Py_FileSystemDefaultEncoding, &bufptr, &len))
987
return NULL;
988
- ch = namebuf[len-1];
989
- if (ch != SEP && ch != ALTSEP && ch != ':')
990
- namebuf[len++] = '/';
+ if (len > 0) {
+ char ch = namebuf[len-1];
+ if (ch != SEP && ch != ALTSEP && ch != ':')
+ namebuf[len++] = '/';
991
+ }
992
strcpy(namebuf + len, "*.*");
993
994
if ((d = PyList_New(0)) == NULL)
0 commit comments