Merge pull request #13417 from donaldsharp/elf_py_fd_semantics

lib: Fix elf_py.c for coverity
This commit is contained in:
Mark Stapp 2023-07-26 07:18:06 -04:00 committed by GitHub
commit ec8d9bc8a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1140,7 +1140,7 @@ static PyObject *elffile_load(PyTypeObject *type, PyObject *args,
fd = open(filename, O_RDONLY | O_NOCTTY);
if (fd < 0 || fstat(fd, &st)) {
PyErr_SetFromErrnoWithFilename(PyExc_OSError, filename);
if (fd > 0)
if (fd >= 0)
close(fd);
goto out;
}