From 73de7bfb2374d2b58817a4720e7de5cd2a1eca1d Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Tue, 28 Feb 2017 08:18:23 +0000
Subject: [PATCH] don't crash if no begin vertex

---
 Mesh/meshGEdge.cpp | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/Mesh/meshGEdge.cpp b/Mesh/meshGEdge.cpp
index 8599b8f1d5..63fa7ed5c8 100644
--- a/Mesh/meshGEdge.cpp
+++ b/Mesh/meshGEdge.cpp
@@ -563,11 +563,12 @@ void meshGEdge::operator() (GEdge *ge)
   // first compute the length of the curve by integrating one
   double length;
   std::vector<IntPoint> Points;
-  if(ge->geomType() == GEntity::Line &&
-      ge->getBeginVertex() == ge->getEndVertex() &&
-      //do not consider closed lines as degenerated
-      (ge->position(0.5) - ge->getBeginVertex()->xyz()).norm() < CTX::instance()->geom.tolerance)
-    length = 0.; // special case t avoid infinite loop in integration
+  if(ge->geomType() == GEntity::Line && ge->getBeginVertex() &&
+     ge->getBeginVertex() == ge->getEndVertex() &&
+     // do not consider closed lines as degenerated
+     (ge->position(0.5) - ge->getBeginVertex()->xyz()).norm() <
+     CTX::instance()->geom.tolerance)
+    length = 0.; // special case to avoid infinite loop in integration
   else
     length = Integration(ge, t_begin, t_end, F_One, Points, 1.e-12 * CTX::instance()->lc);
   ge->setLength(length);
-- 
GitLab