Fix #4835 - undefined behavior - uninitialized mCtx

pull/2163/head
Adam Fandrejewski 6 years ago committed by Bret Curtis
parent 8e3b10b5b4
commit 75c204cdd8

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

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

Loading…
Cancel
Save