Subject: [PATCH 3/7] BRepFill_Filling: WireFromList: We can't assume that a connected edge was found and the iterator is valid or we will crash on Edges.Remove
From: blobfish <blobfish@gmx.com>

Date: Tue, 29 Sep 2020 06:41:32 -0400


---
 src/BRepFill/BRepFill_Filling.cxx | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

--- a/src/BRepFill/BRepFill_Filling.cxx
+++ b/src/BRepFill/BRepFill_Filling.cxx
@@ -95,6 +95,7 @@
   while (!Edges.IsEmpty())
   {
     TopTools_ListIteratorOfListOfShape itl(Edges);
+    bool found = false;
     for (; itl.More(); itl.Next())
     {
       anEdge = TopoDS::Edge(itl.Value());
@@ -116,6 +117,7 @@
           anEdge.Reverse();
           V2 = V3;
         }
+        found=true;
         break;
       }
     }
@@ -127,6 +129,13 @@
     }
     BB.Add(aWire, anEdge);
     Edges.Remove(itl);
+    if (found)
+    {
+      BB.Add(aWire, anEdge);
+      Edges.Remove(itl);
+    }
+    else
+      break;
   }
 
   aWire.Closed(Standard_True);
