From f7008b4419dd0b31c0629a2b71f3e0bc31bceb67 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 31 Dec 2004 04:51:10 +0000
Subject: [PATCH] prevent crash when no contour

---
 Mesh/2D_Mesh.cpp | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/Mesh/2D_Mesh.cpp b/Mesh/2D_Mesh.cpp
index fdb0b8d5f7..8381cbf7f1 100644
--- a/Mesh/2D_Mesh.cpp
+++ b/Mesh/2D_Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: 2D_Mesh.cpp,v 1.68 2004-07-14 22:42:26 geuzaine Exp $
+// $Id: 2D_Mesh.cpp,v 1.69 2004-12-31 04:51:10 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -275,7 +275,7 @@ int mesh_domain(ContourPeek * ListContours, int numcontours,
 
   if(!numcontours) {
     Msg(GERROR, "No contour");
-    return 0;
+    return -1;
   }
 
   numact = 0;
@@ -625,9 +625,10 @@ void Maillage_Automatique_VieuxCode(Surface * pS, Mesh * m, int ori)
     liste[i] = cp;
   }
 
+  int res_mesh_domain = 1;
   if(pS->Method)
-    mesh_domain(liste, List_Nbr(pS->Contours), &M, &N,
-                (CTX.mesh.initial_only == 2));
+    res_mesh_domain = mesh_domain(liste, List_Nbr(pS->Contours), &M, &N,
+				  (CTX.mesh.initial_only == 2));
 
   for(i = 0; i < M.numpoints; i++) {
     if(gPointArray[i].initial < 0) {
@@ -682,7 +683,9 @@ void Maillage_Automatique_VieuxCode(Surface * pS, Mesh * m, int ori)
     //xxxxFree(M.listdel[i]);
 
   }
-  Free(M.listdel);
+  
+  if(res_mesh_domain >= 0)
+    Free(M.listdel);
   Free(gPointArray);
 }
 
-- 
GitLab