mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 21:29:56 +00:00
Merge branch 'fix_undefined_behavior_storetest' into 'master'
Fix #4835 - undefined behavior - uninitialized mCtx Closes #4835 See merge request OpenMW/openmw!64
This commit is contained in:
commit
3a1a24151a
2 changed files with 15 additions and 7 deletions
|
@ -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…
Reference in a new issue