]> git.lyx.org Git - features.git/commitdiff
In fileLock, take in account the case where the file cannot be opened
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 12 Sep 2015 21:49:32 +0000 (23:49 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 12 Sep 2015 21:53:19 +0000 (23:53 +0200)
overity issue 23352

src/support/filetools.cpp

index bab96874e49de3c4b012b868713b91ebe533652d..4c37fa1573d4c06c3ba51c4790462570917a3be8 100644 (file)
@@ -1219,14 +1219,17 @@ int fileLock(const char * lock_file)
        int fd = -1;
 #if defined(HAVE_LOCKF)
        fd = open(lock_file, O_CREAT|O_APPEND|O_SYNC|O_RDWR, 0666);
+       if (fd == -1)
+               return -1;
        if (lockf(fd, F_LOCK, 0) != 0) {
                close(fd);
-               return(-1);
+               return -1;
        }
 #endif
-       return(fd);
+       return fd;
 }
 
+
 void fileUnlock(int fd, const char * /* lock_file*/)
 {
 #if defined(HAVE_LOCKF)