From 64142f9da2a47477eceeb4c2162a68c51bcf5609 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 5 May 2016 15:01:22 -0600 Subject: [PATCH] Avoid calling fclose(NULL) if the sudoers file is not secure and restore_perms() fails. Coverity CID 104090. --- plugins/sudoers/sudoers.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index 767d5a06d..34631a260 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -939,8 +939,10 @@ open_sudoers(const char *sudoers, bool doedit, bool *keepopen) if (!restore_perms()) { /* unable to change back to root */ - fclose(fp); - fp = NULL; + if (fp != NULL) { + fclose(fp); + fp = NULL; + } } debug_return_ptr(fp); -- 2.50.1