mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-22 16:39:40 +00:00
Fix #4835 - undefined behavior - uninitialized mCtx
This commit is contained in:
parent
8e3b10b5b4
commit
75c204cdd8
2 changed files with 15 additions and 7 deletions
|
@ -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)
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue