mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 19:45:40 +00:00
Merge branch 'save_safeguard' into 'master'
Add a safeguard to do not use uninitialized value See merge request OpenMW/openmw!3349
This commit is contained in:
commit
e5d5cbcdd1
1 changed files with 15 additions and 7 deletions
|
@ -355,18 +355,26 @@ namespace MWWorld
|
|||
template <class T, class Id>
|
||||
RecordId TypedDynamicStore<T, Id>::read(ESM::ESMReader& reader, bool overrideOnly)
|
||||
{
|
||||
T record;
|
||||
bool isDeleted = false;
|
||||
if constexpr (!ESM::isESM4Rec(T::sRecordId))
|
||||
{
|
||||
T record;
|
||||
bool isDeleted = false;
|
||||
record.load(reader, isDeleted);
|
||||
}
|
||||
insert(record, overrideOnly);
|
||||
|
||||
if constexpr (std::is_same_v<Id, ESM::RefId>)
|
||||
return RecordId(record.mId, isDeleted);
|
||||
insert(record, overrideOnly);
|
||||
|
||||
if constexpr (std::is_same_v<Id, ESM::RefId>)
|
||||
return RecordId(record.mId, isDeleted);
|
||||
else
|
||||
return RecordId();
|
||||
}
|
||||
else
|
||||
return RecordId();
|
||||
{
|
||||
std::stringstream msg;
|
||||
msg << "Can not load record of type ESM::REC_" << getRecNameString(T::sRecordId).toStringView()
|
||||
<< ": ESM::ESMReader can load only ESM3 records.";
|
||||
throw std::runtime_error(msg.str());
|
||||
}
|
||||
}
|
||||
|
||||
// LandTexture
|
||||
|
|
Loading…
Reference in a new issue