diff --git a/src/common/filesystem/include/fs_filesystem.h b/src/common/filesystem/include/fs_filesystem.h index b559494084..bac46e1bb0 100644 --- a/src/common/filesystem/include/fs_filesystem.h +++ b/src/common/filesystem/include/fs_filesystem.h @@ -202,7 +202,7 @@ protected: int IwadIndex = -1; int MaxIwadIndex = -1; - StringPool* stringpool; + StringPool* stringpool = nullptr; private: void DeleteAll(); diff --git a/src/common/filesystem/source/file_directory.cpp b/src/common/filesystem/source/file_directory.cpp index 84679ffc91..89b9625fc6 100644 --- a/src/common/filesystem/source/file_directory.cpp +++ b/src/common/filesystem/source/file_directory.cpp @@ -96,7 +96,7 @@ FDirectory::FDirectory(const char * directory, StringPool* sp, bool nosubdirflag { auto fn = FS_FullPath(directory); if (fn.back() != '/') fn += '/'; - FileName = sp->Strdup(fn.c_str()); + FileName = stringpool->Strdup(fn.c_str()); } //========================================================================== diff --git a/src/common/filesystem/source/filesystem.cpp b/src/common/filesystem/source/filesystem.cpp index c22682ec0a..cc810cc2e2 100644 --- a/src/common/filesystem/source/filesystem.cpp +++ b/src/common/filesystem/source/filesystem.cpp @@ -194,8 +194,6 @@ static void PrintLastError (FileSystemMessageFunc Printf); FileSystem::FileSystem() { - stringpool = new StringPool(true); - stringpool->shared = true; // will be used by all owned resource files. } FileSystem::~FileSystem () @@ -219,7 +217,7 @@ void FileSystem::DeleteAll () delete Files[i]; } Files.clear(); - delete stringpool; + if (stringpool != nullptr) delete stringpool; stringpool = nullptr; } @@ -248,6 +246,9 @@ bool FileSystem::InitMultipleFiles (std::vector& filenames, LumpFil DeleteAll(); numfiles = 0; + stringpool = new StringPool(true); + stringpool->shared = true; // will be used by all owned resource files. + // first, check for duplicates if (allowduplicates) {