]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Avoid possible buffer overflow when checking face normals
authorDmitry Kostenko <codeforsmile@gmail.com>
Sat, 1 Jan 2022 01:07:34 +0000 (02:07 +0100)
committerx2048 <codeforsmile@gmail.com>
Mon, 7 Mar 2022 22:45:26 +0000 (23:45 +0100)
src/client/mesh.cpp

index 9bbb3a0a8267949a80f744b5a809e3beb162d1da..bec72fb5e79b13f27a89b3043fa12aa644511372 100644 (file)
@@ -348,7 +348,7 @@ bool checkMeshNormals(scene::IMesh *mesh)
                if (!std::isfinite(length) || length < 1e-10f)
                        return false;
 
-               const u16 count = MYMIN(MAX_FACES_TO_CHECK * 3, buffer->getIndexCount());
+               const u16 count = MYMIN(MAX_FACES_TO_CHECK * 3, buffer->getIndexCount() - 3);
                for (u16 i = 0; i < count; i += 3) {
 
                        core::plane3df plane(buffer->getPosition(buffer->getIndices()[i]),