summaryrefslogtreecommitdiff
path: root/lib/elf_py.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2023-04-21 09:12:08 -0400
committerDonald Sharp <sharpd@nvidia.com>2023-04-21 09:12:08 -0400
commita7209c2dbc2b26947ea8807283f0377d3d83452c (patch)
treef3e0177a6a261e6a918fcdd9d42960ccb3eb55dc /lib/elf_py.c
parent6f99cfcd897fa63f24a9e9fcf9999aaf7ad76e69 (diff)
lib: Make coverity happy about close
The error condition handled both failure to open and a fstat failure. Just double check that the close is appropriate to call. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'lib/elf_py.c')
-rw-r--r--lib/elf_py.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/elf_py.c b/lib/elf_py.c
index 05f5aef766..d473dc10cb 100644
--- a/lib/elf_py.c
+++ b/lib/elf_py.c
@@ -1140,7 +1140,8 @@ 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);
- close(fd);
+ if (fd > 0)
+ close(fd);
goto out;
}
w->len = st.st_size;