From 11d858e83d4214f11c492a75da4417e6c6d9d81e Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Fri, 27 Apr 2018 02:14:52 +0100 Subject: [PATCH] fix coverity defects --- browser.c | 5 ++++- mutt/file.c | 15 +++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/browser.c b/browser.c index e1e29b094..64d3a1b5e 100644 --- a/browser.c +++ b/browser.c @@ -2082,7 +2082,10 @@ void mutt_select_file(char *f, size_t flen, int flags, char ***files, int *numfi if (buffy) examine_mailboxes(menu, &state); else - examine_directory(menu, &state, NULL, NULL); + { + if (examine_directory(menu, &state, NULL, NULL) == -1) + break; + } init_menu(&state, menu, title, sizeof(title), buffy); } break; diff --git a/mutt/file.c b/mutt/file.c index e76d97fee..b3e69ab4b 100644 --- a/mutt/file.c +++ b/mutt/file.c @@ -875,8 +875,11 @@ FILE *mutt_file_mkstemp_full(const char *file, int line, const char *func) FILE *fp = fdopen(fd, "w+"); - if (unlink(name) && (errno != ENOENT)) + if ((unlink(name) != 0) && (errno != ENOENT)) + { + mutt_file_fclose(&fp); return NULL; + } MuttLogger(0, file, line, func, 1, "created temp file '%s'\n", name); return fp; @@ -1102,7 +1105,6 @@ int mutt_file_lock(int fd, int excl, int timeout) int count; int attempt; struct stat sb = { 0 }, prev_sb = { 0 }; - int r = 0; struct flock lck; @@ -1141,14 +1143,7 @@ int mutt_file_lock(int fd, int excl, int timeout) sleep(1); } - /* release any other locks obtained in this routine */ - if (r != 0) - { - lck.l_type = F_UNLCK; - fcntl(fd, F_SETLK, &lck); - } - - return r; + return 0; } /** -- 2.50.1