From 7cbd7c703b3d308865b779c598d2b3368c1e22dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 6 Jan 2020 20:53:41 +0100 Subject: [PATCH] MeshTools: fix an OOB access in tipsify(). --- doc/changelog.dox | 2 ++ src/Magnum/MeshTools/Tipsify.cpp | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 0893a1c7d..a0dc2998e 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -188,6 +188,8 @@ See also: - Calling @ref Platform::Sdl2Application::setSwapInterval() with @cpp 0 @ce caused @ref Platform::Sdl2Application::setMinimalLoopPeriod() "setMinimalLoopPeriod()" to be ignored even though Vsync was in fact not enabled. +- Fixed an otherwise harmless OOB access in @ref MeshTools::tipsify() that + could trigger ASan or debug iterator errors @subsection changelog-latest-deprecated Deprecated APIs diff --git a/src/Magnum/MeshTools/Tipsify.cpp b/src/Magnum/MeshTools/Tipsify.cpp index 43f7588cb..b3d437363 100644 --- a/src/Magnum/MeshTools/Tipsify.cpp +++ b/src/Magnum/MeshTools/Tipsify.cpp @@ -57,7 +57,9 @@ void tipsify(std::vector& indices, const UnsignedInt vertexCount, c std::vector candidates; /* For all neighbors of fanning vertex */ - for(UnsignedInt ti = neighborOffset[fanningVertex], t = neighbors[ti]; ti != neighborOffset[fanningVertex+1]; t = neighbors[++ti]) { + for(UnsignedInt ti = neighborOffset[fanningVertex]; ti != neighborOffset[fanningVertex+1]; ++ti) { + const UnsignedInt t = neighbors[ti]; + /* Continue if already emitted */ if(emitted[t]) continue; emitted[t] = true;