Skip to content

Commit

Permalink
Do not freak out if an input polygon is empty (#465)
Browse files Browse the repository at this point in the history
* Modify tests so that they fail

* Add sanity check
  • Loading branch information
reunanen authored Mar 26, 2023
1 parent fb8fdd1 commit 0c7fdf5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CPP/Clipper2Lib/src/clipper.engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion CPP/Tests/TestRandomPaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0c7fdf5

Please sign in to comment.