diff --git a/Geo/GeoUtils.cpp b/Geo/GeoUtils.cpp
index 16b3c9d5b262a7815b57885c42dc635073b8ba2e..3b2fd680a7ab925884daad8fe4580ca983db6ce2 100644
--- a/Geo/GeoUtils.cpp
+++ b/Geo/GeoUtils.cpp
@@ -1,4 +1,4 @@
-// $Id: GeoUtils.cpp,v 1.10 2006-03-29 14:33:51 geuzaine Exp $
+// $Id: GeoUtils.cpp,v 1.11 2006-04-16 02:42:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -50,7 +50,7 @@ void sortEdgesInLoop(int num, List_T *edges)
       // can arise due to a limitation in Read_Mesh, where we do a
       // List_Insert() to add the vertices in discrete curves--so that
       // we never get the last vertex for single, closed curves.)
-      if(nbEdges == 1 && List_Nbr(c->Vertices) && c->Typ == MSH_SEGM_DISCRETE){
+      if(c->Typ == MSH_SEGM_DISCRETE && nbEdges == 1 && List_Nbr(c->Vertices)){
 	Vertex *first = *(Vertex**)List_Pointer(c->Vertices, 0);
 	Vertex *last = *(Vertex**)List_Pointer(c->Vertices, List_Nbr(c->Vertices) - 1);
 	if(first != last){
@@ -58,12 +58,20 @@ void sortEdgesInLoop(int num, List_T *edges)
 	  List_Add(c->Vertices, &first);
 	}
       }
+      // setting end points for discrete curves
+      if(c->Typ == MSH_SEGM_DISCRETE && !c->beg && !c->end && List_Nbr(c->Vertices)){
+	Vertex *first = *(Vertex**)List_Pointer(c->Vertices, 0);
+	Vertex *last = *(Vertex**)List_Pointer(c->Vertices, List_Nbr(c->Vertices) - 1);
+	c->beg = FindPoint(first->Num, THEM);
+	c->end = FindPoint(last->Num, THEM);
+      }
     }
     else
       Msg(GERROR, "Unknown curve %d in line loop %d", j, num);
   }
   List_Reset(edges);
-  
+
+ 
   int j = 0, k = 0;
   c0 = c1 = *(Curve **) List_Pointer(temp, 0);
   List_Add(edges, &c1->Num);
diff --git a/Mesh/2D_Mesh.cpp b/Mesh/2D_Mesh.cpp
index ddbd4f5718819bb6125c9ede0e7e11cb0181a076..85718a142f43d9c93bd4e0d6d710d9a4636ec8b4 100644
--- a/Mesh/2D_Mesh.cpp
+++ b/Mesh/2D_Mesh.cpp
@@ -1,4 +1,4 @@
-// $Id: 2D_Mesh.cpp,v 1.81 2006-01-29 22:53:41 geuzaine Exp $
+// $Id: 2D_Mesh.cpp,v 1.82 2006-04-16 02:42:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -109,6 +109,10 @@ int Calcule_Contours(Surface * s)
   l = List_Create(10, 10, sizeof(Vertex *));
   for(i = 0; i < List_Nbr(s->Generatrices); i++) {
     List_Read(s->Generatrices, i, &c);
+    if(!List_Nbr(c->Vertices)) {
+      Msg(GERROR, "Curve %d has no mesh", c->Num);
+      return 0;
+    }
     if(!List_Nbr(l)) {
       List_Read(c->Vertices, 0, &first);
     }
diff --git a/benchmarks/1d/1d_discrete.geo b/benchmarks/1d/1d_discrete.geo
new file mode 100644
index 0000000000000000000000000000000000000000..bfd4f859b4dc7f107cf9af896ef43c57cb512152
--- /dev/null
+++ b/benchmarks/1d/1d_discrete.geo
@@ -0,0 +1,20 @@
+
+Merge "1d_with_points.msh";
+//Merge "1d_without_points.msh";
+
+Delete Physicals;
+Status 0; // to force remeshing of non-discrete curves
+
+cl=0.0999;
+
+//Point(1) = {0, 0, 0, cl};
+Point(2) = {0, 1, 0, cl};
+Point(3) = {1, 1, 0, cl};
+//Point(4) = {1, 0, 0, cl};
+
+Line(1)={1,2};
+Line(2)={2,3};
+Line(3)={3,4};
+
+Line Loop(1) = {1,2,3,4};
+Plane Surface(1) = {1};
diff --git a/benchmarks/1d/1d_with_points.msh b/benchmarks/1d/1d_with_points.msh
new file mode 100644
index 0000000000000000000000000000000000000000..4c46d793eb7bd1ea55e0c19277b64ce3f927fa37
--- /dev/null
+++ b/benchmarks/1d/1d_with_points.msh
@@ -0,0 +1,13 @@
+$NOD
+3
+1 0 0 0
+4 1 0 0
+5 0.5 0 0
+$ENDNOD
+$ELM
+4
+1 15 1 1 1 1
+4 15 4 4 1 4
+10 1 4 4 2 4 5
+11 1 4 4 2 5 1
+$ENDELM
diff --git a/benchmarks/1d/1d_without_points.msh b/benchmarks/1d/1d_without_points.msh
new file mode 100644
index 0000000000000000000000000000000000000000..ae51b9ef8d5df8b0116485b35b7c53af1c354fdb
--- /dev/null
+++ b/benchmarks/1d/1d_without_points.msh
@@ -0,0 +1,11 @@
+$NOD
+3
+1 0 0 0
+4 1 0 0
+5 0.5 0 0
+$ENDNOD
+$ELM
+2
+10 1 4 4 2 4 5
+11 1 4 4 2 5 1
+$ENDELM