1
0

Merge pull request #2769 from cuberite/FastNBTAsserts

Check for invalid tags when reading a compound tag
This commit is contained in:
Alexander Harkness 2015-12-18 14:40:23 +00:00
commit 05e39b249b

View File

@ -110,7 +110,12 @@ bool cParsedNBT::ReadCompound(void)
for (;;) for (;;)
{ {
NEEDBYTES(1); NEEDBYTES(1);
eTagType TagType = static_cast<eTagType>(m_Data[m_Pos]); const char TagTypeNum = m_Data[m_Pos];
if ((TagTypeNum < TAG_Min) || (TagTypeNum > TAG_Max))
{
return false;
}
eTagType TagType = static_cast<eTagType>(TagTypeNum);
m_Pos++; m_Pos++;
if (TagType == TAG_End) if (TagType == TAG_End)
{ {
@ -258,7 +263,6 @@ bool cParsedNBT::ReadTag(void)
#endif #endif
case TAG_Min: case TAG_Min:
{ {
ASSERT(!"Unhandled NBT tag type");
return false; return false;
} }
} // switch (iType) } // switch (iType)