- fix bad stringpool setup in filesystem.

Doing it in the constructor does not work because InitMultipleFiles will clear everything again before building up the directory so it would always be null.
This triggered another bug in file_directory.cpp which used the constructor's unvalidated parameter.
This commit is contained in:
Professor Hastig 2023-09-13 09:47:09 +02:00 committed by Christoph Oelckers
parent 5cfdd82e0f
commit 8b31e0d3b6
3 changed files with 6 additions and 5 deletions

View file

@ -202,7 +202,7 @@ protected:
int IwadIndex = -1;
int MaxIwadIndex = -1;
StringPool* stringpool;
StringPool* stringpool = nullptr;
private:
void DeleteAll();

View file

@ -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());
}
//==========================================================================

View file

@ -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<std::string>& 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)
{