Fixed crash on attempt to load corrupted data file

Instance of FileReader is no longer destructed when header of data file is valid but complete loading of file fails
Loading of truncated .zip file is the simplest test case
This commit is contained in:
alexey.lysiuk 2014-04-27 10:18:50 +03:00
parent 3f8c7239af
commit 3fa89b4e9f
6 changed files with 12 additions and 0 deletions

View file

@ -351,6 +351,8 @@ FResourceFile *Check7Z(const char *filename, FileReader *file, bool quiet)
{ {
FResourceFile *rf = new F7ZFile(filename, file); FResourceFile *rf = new F7ZFile(filename, file);
if (rf->Open(quiet)) return rf; if (rf->Open(quiet)) return rf;
rf->Reader = NULL; // to avoid destruction of reader
delete rf; delete rf;
} }
} }

View file

@ -147,6 +147,8 @@ FResourceFile *CheckGRP(const char *filename, FileReader *file, bool quiet)
{ {
FResourceFile *rf = new FGrpFile(filename, file); FResourceFile *rf = new FGrpFile(filename, file);
if (rf->Open(quiet)) return rf; if (rf->Open(quiet)) return rf;
rf->Reader = NULL; // to avoid destruction of reader
delete rf; delete rf;
} }
} }

View file

@ -139,6 +139,8 @@ FResourceFile *CheckPak(const char *filename, FileReader *file, bool quiet)
{ {
FResourceFile *rf = new FPakFile(filename, file); FResourceFile *rf = new FPakFile(filename, file);
if (rf->Open(quiet)) return rf; if (rf->Open(quiet)) return rf;
rf->Reader = NULL; // to avoid destruction of reader
delete rf; delete rf;
} }
} }

View file

@ -260,6 +260,8 @@ FResourceFile *CheckRFF(const char *filename, FileReader *file, bool quiet)
{ {
FResourceFile *rf = new FRFFFile(filename, file); FResourceFile *rf = new FRFFFile(filename, file);
if (rf->Open(quiet)) return rf; if (rf->Open(quiet)) return rf;
rf->Reader = NULL; // to avoid destruction of reader
delete rf; delete rf;
} }
} }

View file

@ -651,6 +651,8 @@ FResourceFile *CheckWad(const char *filename, FileReader *file, bool quiet)
{ {
FResourceFile *rf = new FWadFile(filename, file); FResourceFile *rf = new FWadFile(filename, file);
if (rf->Open(quiet)) return rf; if (rf->Open(quiet)) return rf;
rf->Reader = NULL; // to avoid destruction of reader
delete rf; delete rf;
} }
} }

View file

@ -423,6 +423,8 @@ FResourceFile *CheckZip(const char *filename, FileReader *file, bool quiet)
{ {
FResourceFile *rf = new FZipFile(filename, file); FResourceFile *rf = new FZipFile(filename, file);
if (rf->Open(quiet)) return rf; if (rf->Open(quiet)) return rf;
rf->Reader = NULL; // to avoid destruction of reader
delete rf; delete rf;
} }
} }