diff --git a/src/files.cpp b/src/files.cpp index 1e7f83bd6..fee5123ff 100644 --- a/src/files.cpp +++ b/src/files.cpp @@ -348,7 +348,11 @@ public: bool FileReader::OpenFile(const char *filename, FileReader::Size start, FileReader::Size length) { auto reader = new StdFileReader; - if (!reader->Open(filename, (long)start, (long)length)) return false; + if (!reader->Open(filename, (long)start, (long)length)) + { + delete reader; + return false; + } Close(); mReader = reader; return true;