1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-22 17:39:40 +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) , mEncoder(nullptr)
, mFileSize(0) , mFileSize(0)
{ {
clearCtx();
} }
int ESMReader::getFormat() const int ESMReader::getFormat() const
@ -50,6 +51,12 @@ void ESMReader::restoreContext(const ESM_Context &rc)
void ESMReader::close() void ESMReader::close()
{ {
mEsm.reset(); mEsm.reset();
clearCtx();
mHeader.blank();
}
void ESMReader::clearCtx()
{
mCtx.filename.clear(); mCtx.filename.clear();
mCtx.leftFile = 0; mCtx.leftFile = 0;
mCtx.leftRec = 0; mCtx.leftRec = 0;
@ -57,7 +64,6 @@ void ESMReader::close()
mCtx.subCached = false; mCtx.subCached = false;
mCtx.recName.clear(); mCtx.recName.clear();
mCtx.subName.clear(); mCtx.subName.clear();
mHeader.blank();
} }
void ESMReader::openRaw(Files::IStreamPtr _esm, const std::string& name) void ESMReader::openRaw(Files::IStreamPtr _esm, const std::string& name)

View file

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