mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-01 14:39:42 +00:00
Guard an undefined behaviour
`std::vector.back()` on an empty `std::vector` is undefined. This should fix #6725. Thanks to @Capostrophic for the investigation.
This commit is contained in:
parent
5b36ea0179
commit
81bd034a9e
1 changed files with 3 additions and 0 deletions
|
@ -78,6 +78,9 @@ void ESM4::Header::load(ESM4::Reader& reader)
|
||||||
}
|
}
|
||||||
case ESM4::SUB_DATA:
|
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
|
// WARNING: assumes DATA always follows MAST
|
||||||
if (!reader.getExact(mMaster.back().size))
|
if (!reader.getExact(mMaster.back().size))
|
||||||
throw std::runtime_error("TES4 DATA data read error");
|
throw std::runtime_error("TES4 DATA data read error");
|
||||||
|
|
Loading…
Reference in a new issue