1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-21 22:39:39 +00:00

Fix #4835 - undefined behavior - uninitialized mCtx

This commit is contained in:
Adam Fandrejewski 2019-02-23 13:35:25 +00:00 committed by Bret Curtis
parent 8e3b10b5b4
commit 75c204cdd8
2 changed files with 15 additions and 7 deletions

View file

@ -27,6 +27,7 @@ ESMReader::ESMReader()
, mEncoder(nullptr)
, mFileSize(0)
{
clearCtx();
}
int ESMReader::getFormat() const
@ -50,6 +51,12 @@ void ESMReader::restoreContext(const ESM_Context &rc)
void ESMReader::close()
{
mEsm.reset();
clearCtx();
mHeader.blank();
}
void ESMReader::clearCtx()
{
mCtx.filename.clear();
mCtx.leftFile = 0;
mCtx.leftRec = 0;
@ -57,7 +64,6 @@ void ESMReader::close()
mCtx.subCached = false;
mCtx.recName.clear();
mCtx.subName.clear();
mHeader.blank();
}
void ESMReader::openRaw(Files::IStreamPtr _esm, const std::string& name)

View file

@ -269,6 +269,8 @@ public:
size_t getFileSize() const { return mFileSize; }
private:
void clearCtx();
Files::IStreamPtr mEsm;
ESM_Context mCtx;