From 5373fdf3adbb56adc73d435884a0029d79491480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 28 Jan 2014 13:16:32 +0100 Subject: [PATCH] MeshTools: fix obvious out-of-range access in tipsify(). Spotted by MSVC compiler (which does range check on everything). This was probably harmless, as the out-of-range memory wasn't accessed afterwards (the for cycle would end right after that because vi == 3), but it was firing the assertion so it's better to have it fixed. --- src/Magnum/MeshTools/Tipsify.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Magnum/MeshTools/Tipsify.cpp b/src/Magnum/MeshTools/Tipsify.cpp index fba38cf16..e68402ca4 100644 --- a/src/Magnum/MeshTools/Tipsify.cpp +++ b/src/Magnum/MeshTools/Tipsify.cpp @@ -61,7 +61,9 @@ void Tipsify::operator()(std::size_t cacheSize) { emitted[t] = true; /* Write all vertices of the triangle to output buffer */ - for(UnsignedInt vi = 0, v = indices[t*3]; vi != 3; v = indices[++vi+t*3]) { + for(UnsignedInt vi = 0; vi != 3; ++vi) { + const UnsignedInt v = indices[vi + t*3]; + outputIndices.push_back(v); /* Add to dead end stack and candidates array */