diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c index 46fed6e7fd7..50e69826638 100644 --- a/Python/dynload_shlib.c +++ b/Python/dynload_shlib.c @@ -81,7 +81,9 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname, if (fp != NULL) { int i; struct stat statb; - fstat(fileno(fp), &statb); + if (fstat(fileno(fp), &statb) == -1) { + return PyErr_SetFromErrno(PyExc_IOError); + } for (i = 0; i < nhandles; i++) { if (statb.st_dev == handles[i].dev && statb.st_ino == handles[i].ino) {