[New-bugs-announce] [issue18332] _posix_listdir may leak FD
Christian Heimes
report at bugs.python.org
Sun Jun 30 18:47:57 CEST 2013
New submission from Christian Heimes:
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
----------
components: Extension Modules
messages: 192077
nosy: christian.heimes
priority: normal
severity: normal
stage: needs patch
status: open
title: _posix_listdir may leak FD
type: resource usage
versions: Python 3.3, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18332>
_______________________________________
More information about the New-bugs-announce
mailing list