From d6f9c87a744ad66a504301200c79b30e4d644c6f Mon Sep 17 00:00:00 2001 From: Juha Reunanen Date: Sun, 26 Mar 2023 11:12:28 +0300 Subject: [PATCH 1/2] Modify tests so that they fail --- CPP/Tests/TestRandomPaths.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CPP/Tests/TestRandomPaths.cpp b/CPP/Tests/TestRandomPaths.cpp index 874fd6ec..f8ff1ab5 100644 --- a/CPP/Tests/TestRandomPaths.cpp +++ b/CPP/Tests/TestRandomPaths.cpp @@ -22,7 +22,7 @@ Clipper2Lib::Paths64 GenerateRandomPaths(std::default_random_engine& rng, int mi for (int path = 0; path < path_count; ++path) { - const int min_point_count = 3; + const int min_point_count = 0; const int path_length = GenerateRandomInt(rng, min_point_count, std::max(min_point_count, max_complexity)); auto& result_path = result[path]; result_path.reserve(path_length); From 483401b15a6f54e48276e4629f60307ffa707398 Mon Sep 17 00:00:00 2001 From: Juha Reunanen Date: Sun, 26 Mar 2023 11:13:04 +0300 Subject: [PATCH 2/2] Add sanity check --- CPP/Clipper2Lib/src/clipper.engine.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CPP/Clipper2Lib/src/clipper.engine.cpp b/CPP/Clipper2Lib/src/clipper.engine.cpp index 63031df1..2d61b8aa 100644 --- a/CPP/Clipper2Lib/src/clipper.engine.cpp +++ b/CPP/Clipper2Lib/src/clipper.engine.cpp @@ -594,6 +594,9 @@ namespace Clipper2Lib { //for each path create a circular double linked list of vertices Vertex* v0 = v, * curr_v = v, * prev_v = nullptr; + if (path.empty()) + continue; + v->prev = nullptr; int cnt = 0; for (const Point64& pt : path)