From 6fd9c200acfd8f7abf21bbaf15fccb96713cf1ab Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sun, 16 Oct 2022 08:41:30 +0100 Subject: [PATCH] Fix coverity scan 1499796 --- common/misc_mosq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/misc_mosq.c b/common/misc_mosq.c index 3b167943..b8a1944c 100644 --- a/common/misc_mosq.c +++ b/common/misc_mosq.c @@ -131,6 +131,7 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read) } #else FILE *fptr; + struct stat statbuf; if(restrict_read){ mode_t old_mask; @@ -141,8 +142,8 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read) }else{ fptr = fopen(path, mode); } + if(!fptr) return NULL; - struct stat statbuf; if(fstat(fileno(fptr), &statbuf) < 0){ fclose(fptr); return NULL;