From c49688fd7d64538a1faadd3d0930a0ff434581c0 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Sun, 28 May 2017 21:26:49 -0300 Subject: [PATCH] Verify if a certain resource exists before do any other sanity check --- src/utils/system.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils/system.cc b/src/utils/system.cc index 2898edcc..1054b2ee 100644 --- a/src/utils/system.cc +++ b/src/utils/system.cc @@ -147,6 +147,9 @@ bool createDir(std::string dir, int mode, std::string *error) { bool isFile(std::string f) { struct stat fileInfo; FILE *fp = fopen(f.c_str(), "r"); + if (fp == NULL) { + return false; + } fstat(fileno(fp), &fileInfo); if (!S_ISREG(fileInfo.st_mode)) { fclose(fp);