Issue 18332: _posix_listdir may leak FD
Issue18332
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2013-06-30 16:47 by christian.heimes, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg192077 - (view) | Author: Christian Heimes (christian.heimes) * ![]() |
Date: 2013-06-30 16:47 | |
Under rare circumstances listdir() could leak a FD:
- HAVE_FDOPENDIR is defined
- dup(fd) succeeds
- fdopendir() fails and sets dirp to NULL
- if (dirp == NULL) goto exit
- the dupped fd isn't closed because exit just handles dirp != NULL.
Proposed fix:
if (dirp != NULL) {
...
} else if (fd != -1) {
close(fd);
}
CID 992693 (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_handle: Handle variable "fd" going out of scope leaks the handle
|
|||
| msg192080 - (view) | Author: Richard Oudkerk (sbt) * ![]() |
Date: 2013-06-30 17:26 | |
I think this is a duplicate of #17899. |
|||
| msg192082 - (view) | Author: Christian Heimes (christian.heimes) * ![]() |
Date: 2013-06-30 17:43 | |
You are right. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:47 | admin | set | github: 62532 |
| 2013-06-30 17:43:23 | christian.heimes | set | status: open -> closed superseder: os.listdir() leaks FDs if invoked on FD pointing to a non-directory resolution: duplicate messages: + msg192082 |
| 2013-06-30 17:26:50 | sbt | set | nosy:
+ sbt messages: + msg192080 |
| 2013-06-30 16:47:57 | christian.heimes | create | |
