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;