1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-11-29 17:04:29 +00:00

Clamp index before subtracting

This commit is contained in:
Evil Eye 2025-11-14 16:45:32 +01:00
parent 447e01504e
commit f2dd080c14

View file

@ -27,6 +27,7 @@ size_t MWGui::wrap(size_t index, size_t max, int delta)
return index + absDelta;
}
size_t absDelta = static_cast<size_t>(-static_cast<ptrdiff_t>(delta));
index = std::min(index, max);
if (index >= absDelta)
return index - absDelta;
else if (max == 0)