mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Fix some more memory leaks (in error conditions) introduced in r58455.
Also fix some indentation.
This commit is contained in:
parent
4167ebcfee
commit
6c91378011
1 changed files with 4 additions and 3 deletions
|
|
@ -2139,7 +2139,8 @@ posix_listdir(PyObject *self, PyObject *args)
|
||||||
Py_FileSystemDefaultEncoding, &name, &len))
|
Py_FileSystemDefaultEncoding, &name, &len))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (len >= MAX_PATH) {
|
if (len >= MAX_PATH) {
|
||||||
PyErr_SetString(PyExc_ValueError, "path too long");
|
PyMem_Free(name);
|
||||||
|
PyErr_SetString(PyExc_ValueError, "path too long");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strcpy(namebuf, name);
|
strcpy(namebuf, name);
|
||||||
|
|
@ -2150,7 +2151,7 @@ posix_listdir(PyObject *self, PyObject *args)
|
||||||
namebuf[len++] = SEP;
|
namebuf[len++] = SEP;
|
||||||
strcpy(namebuf + len, "*.*");
|
strcpy(namebuf + len, "*.*");
|
||||||
|
|
||||||
if ((d = PyList_New(0)) == NULL) {
|
if ((d = PyList_New(0)) == NULL) {
|
||||||
PyMem_Free(name);
|
PyMem_Free(name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -2164,7 +2165,7 @@ posix_listdir(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
if (rc != NO_ERROR) {
|
if (rc != NO_ERROR) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return posix_error_with_filename(name);
|
return posix_error_with_allocated_filename(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (srchcnt > 0) { /* If Directory is NOT Totally Empty, */
|
if (srchcnt > 0) { /* If Directory is NOT Totally Empty, */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue