From 0b2ef4733ac6df1a5909d174bc8ea1b94ea074f6 Mon Sep 17 00:00:00 2001 From: Shubham Vasudeo Desai Date: Mon, 14 Oct 2024 19:29:42 -0400 Subject: [PATCH 1/4] null check --- vector/v.hull/chull.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/vector/v.hull/chull.c b/vector/v.hull/chull.c index 93dfd15742e..9d2972251d2 100644 --- a/vector/v.hull/chull.c +++ b/vector/v.hull/chull.c @@ -687,16 +687,19 @@ void CleanEdges(void) e = edges; DELETE(edges, e); } - e = edges->next; - do { - if (e->delete) { - t = e; - e = e->next; - DELETE(edges, t); - } - else - e = e->next; - } while (e != edges); + if (edges) { + e = edges->next; + do { + if (e && e->delete) { + t = e; + e = e->next; + DELETE(edges, t); + } + else + e = e->next; + } while (e != edges && e != NULL); + } + } /*--------------------------------------------------------------------- From f2182901159685cb2e38ba239951d900a6c854f8 Mon Sep 17 00:00:00 2001 From: ShubhamDesai <42180509+ShubhamDesai@users.noreply.github.com> Date: Mon, 14 Oct 2024 19:39:54 -0400 Subject: [PATCH 2/4] Update vector/v.hull/chull.c Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- vector/v.hull/chull.c | 1 - 1 file changed, 1 deletion(-) diff --git a/vector/v.hull/chull.c b/vector/v.hull/chull.c index 9d2972251d2..a9495fd01c7 100644 --- a/vector/v.hull/chull.c +++ b/vector/v.hull/chull.c @@ -699,7 +699,6 @@ void CleanEdges(void) e = e->next; } while (e != edges && e != NULL); } - } /*--------------------------------------------------------------------- From 255d272e90f0e4ae90f523370927b1f5020c033d Mon Sep 17 00:00:00 2001 From: Shubham Vasudeo Desai Date: Tue, 15 Oct 2024 14:21:49 -0400 Subject: [PATCH 3/4] requested changes --- vector/v.hull/chull.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vector/v.hull/chull.c b/vector/v.hull/chull.c index 9d2972251d2..fc1ff73d989 100644 --- a/vector/v.hull/chull.c +++ b/vector/v.hull/chull.c @@ -690,14 +690,14 @@ void CleanEdges(void) if (edges) { e = edges->next; do { - if (e && e->delete) { + if (e->delete) { t = e; e = e->next; DELETE(edges, t); } else e = e->next; - } while (e != edges && e != NULL); + } while (e != edges); } } From 22208fc8616fcfb4b672f190f0ca57e9cc823a51 Mon Sep 17 00:00:00 2001 From: Shubham Vasudeo Desai Date: Sun, 20 Oct 2024 17:35:17 -0400 Subject: [PATCH 4/4] early return --- vector/v.hull/chull.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/vector/v.hull/chull.c b/vector/v.hull/chull.c index 0564e6c2c1f..cd8dcf52153 100644 --- a/vector/v.hull/chull.c +++ b/vector/v.hull/chull.c @@ -687,18 +687,18 @@ void CleanEdges(void) e = edges; DELETE(edges, e); } - if (edges) { - e = edges->next; - do { - if (e->delete) { - t = e; - e = e->next; - DELETE(edges, t); - } - else - e = e->next; - } while (e != edges); - } + if (!edges) + return; + e = edges->next; + do { + if (e->delete) { + t = e; + e = e->next; + DELETE(edges, t); + } + else + e = e->next; + } while (e != edges); } /*--------------------------------------------------------------------- @@ -713,6 +713,8 @@ void CleanFaces(void) f = faces; DELETE(faces, f); } + if (!faces) + return; f = faces->next; do { if (f->visible) { @@ -748,6 +750,8 @@ void CleanVertices(void) v = vertices; DELETE(vertices, v); } + if (!vertices) + return; v = vertices->next; do { if (v->mark && !v->onhull) {