1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-24 18:39:59 +00:00

Merge branch 'fix_empty_vector' into 'master'

Guard an undefined behaviour

Closes #6725

See merge request OpenMW/openmw!3037
This commit is contained in:
psi29a 2023-05-21 17:33:13 +00:00
commit e1754b840a

View File

@ -78,6 +78,9 @@ void ESM4::Header::load(ESM4::Reader& reader)
}
case ESM4::SUB_DATA:
{
if (mMaster.empty())
throw std::runtime_error(
"Failed to read TES4 DATA subrecord: there is no preceding MAST subrecord");
// WARNING: assumes DATA always follows MAST
if (!reader.getExact(mMaster.back().size))
throw std::runtime_error("TES4 DATA data read error");