summaryrefslogtreecommitdiffstats
path: root/Modules/_fileio.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_fileio.c')
-rw-r--r--Modules/_fileio.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/_fileio.c b/Modules/_fileio.c
index 339a1d7..1ed6417 100644
--- a/Modules/_fileio.c
+++ b/Modules/_fileio.c
@@ -146,7 +146,7 @@ check_fd(int fd)
{
#if defined(HAVE_FSTAT)
struct stat buf;
- if (fstat(fd, &buf) < 0 && errno == EBADF) {
+ if (!_PyVerify_fd(fd) || (fstat(fd, &buf) < 0 && errno == EBADF)) {
PyObject *exc;
char *msg = strerror(EBADF);
exc = PyObject_CallFunction(PyExc_OSError, "(is)",