Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
554c63fa
Commit
554c63fa
authored
Aug 01, 2013
by
Larry Hastings
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #17899: Fix rare file descriptor leak in os.listdir().
parent
fc24634e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
Misc/NEWS
Misc/NEWS
+2
-0
Modules/posixmodule.c
Modules/posixmodule.c
+12
-2
No files found.
Misc/NEWS
View file @
554c63fa
...
...
@@ -10,6 +10,8 @@ What's New in Python 3.4.0 Alpha 1?
Core and Builtins
-----------------
- Issue #17899: Fix rare file descriptor leak in os.listdir().
- Issue #10241: Clear extension module dict copies at interpreter shutdown.
Patch by Neil Schemenauer, minimally modified.
...
...
Modules/posixmodule.c
View file @
554c63fa
...
...
@@ -3420,12 +3420,13 @@ exit:
static
PyObject
*
_posix_listdir
(
path_t
*
path
,
PyObject
*
list
)
{
int
fd
=
-
1
;
PyObject
*
v
;
DIR
*
dirp
=
NULL
;
struct
dirent
*
ep
;
int
return_str
;
/* if false, return bytes */
#ifdef HAVE_FDOPENDIR
int
fd
=
-
1
;
#endif
errno
=
0
;
#ifdef HAVE_FDOPENDIR
...
...
@@ -3467,6 +3468,13 @@ _posix_listdir(path_t *path, PyObject *list)
if
(
dirp
==
NULL
)
{
list
=
path_error
(
path
);
#ifdef HAVE_FDOPENDIR
if
(
fd
!=
-
1
)
{
Py_BEGIN_ALLOW_THREADS
close
(
fd
);
Py_END_ALLOW_THREADS
}
#endif
goto
exit
;
}
if
((
list
=
PyList_New
(
0
))
==
NULL
)
{
...
...
@@ -3509,8 +3517,10 @@ _posix_listdir(path_t *path, PyObject *list)
exit:
if
(
dirp
!=
NULL
)
{
Py_BEGIN_ALLOW_THREADS
#ifdef HAVE_FDOPENDIR
if
(
fd
>
-
1
)
rewinddir
(
dirp
);
#endif
closedir
(
dirp
);
Py_END_ALLOW_THREADS
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment