From 677c9eed7be24a0cc72d7f222f735089a91f0c7e Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Mon, 14 Jul 2008 10:42:23 +0000
Subject: [PATCH] fix crash in face/region info string

---
 Geo/GFace.cpp   |  5 ++---
 Geo/GRegion.cpp | 23 ++++++++++++-----------
 doc/CREDITS.txt |  2 +-
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp
index fba5f4e672..f20e23be58 100644
--- a/Geo/GFace.cpp
+++ b/Geo/GFace.cpp
@@ -159,14 +159,13 @@ std::string GFace::getAdditionalInfoString()
   if(l_edges.empty()) return std::string("");
 
   std::string str("{");
-  std::list<GEdge*>::const_iterator it = l_edges.begin();
   if(l_edges.size() > 10){
-    std::list<GEdge*>::const_iterator ite = l_edges.end();
     char tmp[256];
-    sprintf(tmp, "%d, ..., %d", (*it)->tag(), (*ite)->tag());
+    sprintf(tmp, "%d, ..., %d", l_edges.front()->tag(), l_edges.back()->tag());
     str += tmp;
   }
   else{
+    std::list<GEdge*>::const_iterator it = l_edges.begin();
     for(; it != l_edges.end(); it++){
       if(it != l_edges.begin()) str += ",";
       char tmp[256];
diff --git a/Geo/GRegion.cpp b/Geo/GRegion.cpp
index 492013cb75..ced3ab2415 100644
--- a/Geo/GRegion.cpp
+++ b/Geo/GRegion.cpp
@@ -130,20 +130,21 @@ std::string GRegion::getAdditionalInfoString()
 {
   if(l_faces.empty()) return std::string("");
 
-  char tmp[256];
+  std::string str("{");
   if(l_faces.size() > 10){
-    sprintf(tmp, "{%d, ..., %d}", (*l_faces.begin())->tag(), (*l_faces.end())->tag());
-    return std::string(tmp);
-  }
-
-  std::string str("");
-  std::list<GFace*>::const_iterator it = l_faces.begin();
-  str += "{";
-  for(; it != l_faces.end(); it++){
-    if(it != l_faces.begin()) str += ",";
-    sprintf(tmp, "%d", (*it)->tag());
+    char tmp[256];
+    sprintf(tmp, "%d, ..., %d", l_faces.front()->tag(), l_faces.back()->tag());
     str += tmp;
   }
+  else{
+    std::list<GFace*>::const_iterator it = l_faces.begin();
+    for(; it != l_faces.end(); it++){
+      if(it != l_faces.begin()) str += ",";
+      char tmp[256];
+      sprintf(tmp, "%d", (*it)->tag());
+      str += tmp;
+    }
+  }
   str += "}";
   return str;
 }
diff --git a/doc/CREDITS.txt b/doc/CREDITS.txt
index d5e63d10de..aa7d10b4e8 100644
--- a/doc/CREDITS.txt
+++ b/doc/CREDITS.txt
@@ -101,4 +101,4 @@ Dardenne, Christophe Prud'homme, Sebastien.Clerc, Jose Miguel Pasini,
 Philippe Lussou, Jacques Kools, Bayram Yenikaya, Peter Hornby, Krishna
 Mohan Gundu, Christopher Stott, Timmy Schumacher, Carl Osterwisch,
 Bruno Frackowiak, Philip Kelleners, Romuald Conty, Ruth Sabariego,
-Renaud Sizaire, Michel Benhamou, Emilie Marchandise.
+Renaud Sizaire, Michel Benhamou, Emilie Marchandise, Tom De Vuyst.
-- 
GitLab