diff --git a/src/Mod/Mesh/App/Core/Segmentation.cpp b/src/Mod/Mesh/App/Core/Segmentation.cpp index 15fa0fe18b..983d8c6da9 100644 --- a/src/Mod/Mesh/App/Core/Segmentation.cpp +++ b/src/Mod/Mesh/App/Core/Segmentation.cpp @@ -493,7 +493,10 @@ void MeshSegmentAlgorithm::FindSegments(std::vector& segm) iCur = std::find_if(iBeg, iEnd, std::bind2nd(MeshCore::MeshIsNotFlag(), MeshCore::MeshFacet::VISIT)); - startFacet = iCur - iBeg; + if (iCur < iEnd) + startFacet = iCur - iBeg; + else + startFacet = ULONG_MAX; while (startFacet != ULONG_MAX) { // collect all facets of the same geometry std::vector indices;