Browse Source

MeshTools: regression test for an OOB access in tipsify().

That was harder than I thought.
pull/415/head
Vladimír Vondruš 6 years ago
parent
commit
6b1d4a4f08
  1. 13
      src/Magnum/MeshTools/Test/TipsifyTest.cpp

13
src/Magnum/MeshTools/Test/TipsifyTest.cpp

@ -36,6 +36,7 @@ struct TipsifyTest: TestSuite::Tester {
void buildAdjacency();
void tipsify();
void oneDegenerateTriangle();
};
/*
@ -82,7 +83,8 @@ constexpr std::size_t VertexCount = 19;
TipsifyTest::TipsifyTest() {
addTests({&TipsifyTest::buildAdjacency,
&TipsifyTest::tipsify});
&TipsifyTest::tipsify,
&TipsifyTest::oneDegenerateTriangle});
}
void TipsifyTest::buildAdjacency() {
@ -158,6 +160,15 @@ void TipsifyTest::tipsify() {
}));
}
void TipsifyTest::oneDegenerateTriangle() {
/* There used to be an OOB access (neighbors[++ti]) caught by ASan, this
triggers it */
std::vector<UnsignedInt> indices{0, 0, 0};
MeshTools::tipsify(indices, 1, 2);
CORRADE_COMPARE(indices, (std::vector<UnsignedInt>{0, 0, 0}));
}
}}}}
CORRADE_TEST_MAIN(Magnum::MeshTools::Test::TipsifyTest)

Loading…
Cancel
Save