~ fix segmentation fault reported on #22

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2020-07-28 10:55:56 +02:00
parent 79e9ead2ee
commit 3730ac438f
2 changed files with 16 additions and 7 deletions

View File

@ -7,7 +7,7 @@ namespace WallpaperEngine::Irrlicht
m_context (context) m_context (context)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CArchiveLoaderWAD"); setDebugName("CArchiveLoaderPKG");
#endif #endif
} }
@ -37,7 +37,7 @@ namespace WallpaperEngine::Irrlicht
if (file) if (file)
{ {
file->seek (0); file->seek (0);
archive = new CPkgReader (file, ignoreCase, ignorePaths); archive = new CPkgReader (this->m_context, file, ignoreCase, ignorePaths);
} }
return archive; return archive;
@ -58,7 +58,11 @@ namespace WallpaperEngine::Irrlicht
file->read (pointer, size - 1); file->read (pointer, size - 1);
if (strcmp (pointer, "PKGV0002") != 0 && strcmp (pointer, "PKGV0001") != 0)
if (
strcmp ("PKGV0007", pointer) != 0 &&
strcmp ("PKGV0002", pointer) != 0 &&
strcmp ("PKGV0001", pointer) != 0)
{ {
delete [] pointer; delete [] pointer;
return false; return false;
@ -74,8 +78,10 @@ namespace WallpaperEngine::Irrlicht
return false; return false;
} }
CPkgReader::CPkgReader (irr::io::IReadFile* file, bool ignoreCase, bool ignorePaths) CPkgReader::CPkgReader (CContext* context, irr::io::IReadFile* file, bool ignoreCase, bool ignorePaths)
: CFileList((file ? file->getFileName() : irr::io::path("")), ignoreCase, ignorePaths), m_file(file) : CFileList((file ? file->getFileName() : irr::io::path("")), ignoreCase, ignorePaths),
m_file(file),
m_context (context)
{ {
if (this->m_file) if (this->m_file)
{ {
@ -104,7 +110,10 @@ namespace WallpaperEngine::Irrlicht
{ {
char* headerVersion = this->readSizedString (); char* headerVersion = this->readSizedString ();
if (strcmp ("PKGV0007", headerVersion) != 0 && strcmp ("PKGV0002", headerVersion) != 0 && strcmp ("PKGV0001", headerVersion) != 0) if (
strcmp ("PKGV0007", headerVersion) != 0 &&
strcmp ("PKGV0002", headerVersion) != 0 &&
strcmp ("PKGV0001", headerVersion) != 0)
{ {
delete [] headerVersion; delete [] headerVersion;

View File

@ -50,7 +50,7 @@ namespace WallpaperEngine::Irrlicht
public: public:
//! constructor //! constructor
CPkgReader (irr::io::IReadFile *file, bool ignoreCase, bool ignorePaths); CPkgReader (CContext* context, irr::io::IReadFile *file, bool ignoreCase, bool ignorePaths);
//! destructor //! destructor
virtual ~CPkgReader (); virtual ~CPkgReader ();