]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Make coverity happy about close
authorDonald Sharp <sharpd@nvidia.com>
Fri, 21 Apr 2023 13:12:08 +0000 (09:12 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Fri, 21 Apr 2023 13:12:08 +0000 (09:12 -0400)
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>
lib/elf_py.c

index 05f5aef766fb4080fbc52d7e61d37103d49e824b..d473dc10cbf0ece5eeb465f419bec8a768e5d235 100644 (file)
@@ -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;