1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00

Extend variables range to avoid integer overflow

This commit is contained in:
Andrei Kortunov 2021-04-14 08:06:22 +04:00
parent fcb3fffb9a
commit 696cf9ab05

View File

@ -363,11 +363,11 @@ void NiSkinPartition::read(NIFStream *nif)
void NiSkinPartition::Partition::read(NIFStream *nif) void NiSkinPartition::Partition::read(NIFStream *nif)
{ {
unsigned short numVertices = nif->getUShort(); size_t numVertices = nif->getUShort();
unsigned short numTriangles = nif->getUShort(); size_t numTriangles = nif->getUShort();
unsigned short numBones = nif->getUShort(); size_t numBones = nif->getUShort();
unsigned short numStrips = nif->getUShort(); size_t numStrips = nif->getUShort();
unsigned short bonesPerVertex = nif->getUShort(); size_t bonesPerVertex = nif->getUShort();
if (numBones) if (numBones)
nif->getUShorts(bones, numBones); nif->getUShorts(bones, numBones);
@ -395,7 +395,7 @@ void NiSkinPartition::Partition::read(NIFStream *nif)
if (numStrips) if (numStrips)
{ {
strips.resize(numStrips); strips.resize(numStrips);
for (unsigned short i = 0; i < numStrips; i++) for (size_t i = 0; i < numStrips; i++)
nif->getUShorts(strips[i], stripLengths[i]); nif->getUShorts(strips[i], stripLengths[i]);
} }
else if (numTriangles) else if (numTriangles)