Fixed issue 1757 (Triangles::clear () use-after-free) plus another uninitialized value. Added tests.

This commit is contained in:
Matthias Koefferlein 2024-06-29 20:01:39 +02:00
parent 564861abe1
commit 7397b8e4e6
2 changed files with 9 additions and 2 deletions

View File

@ -37,7 +37,7 @@ namespace db
{
Triangles::Triangles ()
: m_is_constrained (false), m_level (0), m_flips (0), m_hops (0)
: m_is_constrained (false), m_level (0), m_id (0), m_flips (0), m_hops (0)
{
// .. nothing yet ..
}
@ -1414,8 +1414,8 @@ Triangles::remove_outside_triangles ()
void
Triangles::clear ()
{
m_edges_heap.clear ();
mp_triangles.clear ();
m_edges_heap.clear ();
m_vertex_heap.clear ();
m_returned_edges.clear ();
m_is_constrained = false;

View File

@ -63,6 +63,13 @@ TEST(basic)
EXPECT_EQ (tris.to_string (), "((1, 0), (1, 4), (5, 0)), ((1, 4), (5, 4), (5, 0))");
EXPECT_EQ (tris.check (), true);
tris.clear ();
EXPECT_EQ (tris.bbox ().to_string (), "()");
EXPECT_EQ (tris.to_string (), "");
EXPECT_EQ (tris.check (), true);
}
TEST(flip)