diff --git a/tools/io.h b/tools/io.h index aff9eabd..83a85c1d 100644 --- a/tools/io.h +++ b/tools/io.h @@ -89,7 +89,7 @@ bool ReadBinaryFile(const char* filename, std::vector* data) { ReadFile(fp, data); bool succeeded = WasFileCorrectlyRead(fp, filename); - if (use_file) fclose(fp); + if (use_file && fp) fclose(fp); return succeeded; } @@ -111,7 +111,7 @@ bool ReadTextFile(const char* filename, std::vector* data) { ReadFile(fp, data); bool succeeded = WasFileCorrectlyRead(fp, filename); - if (use_file) fclose(fp); + if (use_file && fp) fclose(fp); return succeeded; }