diff --git a/src/resourcefiles/resourcefile.cpp b/src/resourcefiles/resourcefile.cpp index 603606341..c9f2f7446 100644 --- a/src/resourcefiles/resourcefile.cpp +++ b/src/resourcefiles/resourcefile.cpp @@ -291,11 +291,13 @@ static CheckFunc funcs[] = { CheckWad, CheckZip, Check7Z, CheckPak, CheckGRP, Ch FResourceFile *FResourceFile::OpenResourceFile(const char *filename, FileReader *file, bool quiet, bool containeronly) { + bool mustclose = false; if (file == NULL) { try { file = new FileReader(filename); + mustclose = true; } catch (CRecoverableError &) { @@ -307,6 +309,7 @@ FResourceFile *FResourceFile::OpenResourceFile(const char *filename, FileReader FResourceFile *resfile = funcs[i](filename, file, quiet); if (resfile != NULL) return resfile; } + if (mustclose) delete file; return NULL; }