From 1e4adc512e1901e2c031bd375afe2825692620a5 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Sat, 12 Sep 2015 23:49:32 +0200 Subject: [PATCH] In fileLock, take in account the case where the file cannot be opened overity issue 23352 --- src/support/filetools.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp index bab96874e4..4c37fa1573 100644 --- a/src/support/filetools.cpp +++ b/src/support/filetools.cpp @@ -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) -- 2.39.5