From 6f82ab8941344d59e655a0976a61003db9d3aba6 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Mon, 3 Nov 2014 15:57:34 -0500 Subject: [PATCH] Don't crash when you can't open a file that doesn't exist --- CLTool/src/decomp.cpp | 1 - IO/src/FileStreamUnix.cpp | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CLTool/src/decomp.cpp b/CLTool/src/decomp.cpp index ba8d9e2..e808acf 100644 --- a/CLTool/src/decomp.cpp +++ b/CLTool/src/decomp.cpp @@ -71,7 +71,6 @@ int main(int argc, char **argv) { ImageFile imgf (argv[1]); if(!imgf.Load()) { - fprintf(stderr, "Error loading file: %s\n", argv[1]); return 1; } diff --git a/IO/src/FileStreamUnix.cpp b/IO/src/FileStreamUnix.cpp index 0124050..775175a 100644 --- a/IO/src/FileStreamUnix.cpp +++ b/IO/src/FileStreamUnix.cpp @@ -95,7 +95,9 @@ public: } ~FileStreamImpl() { - fclose(m_FilePtr); + if (0 != m_FilePtr) { + fclose(m_FilePtr); + } } void IncreaseReferenceCount() { m_ReferenceCount++; }