[Gmsh] Crash bug fix for Gmsh

liangvico vicoliang at live.cn
Fri Dec 25 03:45:12 CET 2015


Dear Gmsh Author,
 
There is a crash bug in below function which marked with color:
 
The vertex in _sizes is 2d vertex, so it should alwasy find nothing with 3d vertex V0, V1.
 
void backgroundMesh::updateSizes(GFace *_gf)
{
////////// Ignored ////////

  const double _beta = 1.3;
  for (int i=0;i<3;i++){
    std::set<MEdge,Less_Edge>::iterator it = edges.begin();
    for ( ; it != edges.end(); ++it){
      MVertex *v0 = it->getVertex(0);
      MVertex *v1 = it->getVertex(1);    
 
      // Old code
      //MVertex *V0 = _2Dto3D[v0];
      //MVertex *V1 = _2Dto3D[v1];
      //std::map<MVertex*,double>::iterator s0 = _sizes.find(V0);
      //std::map<MVertex*,double>::iterator s1 = _sizes.find(V1);
 
      // Fixed code
      std::map<MVertex*, double>::iterator s0 = _sizes.find(v0);
      std::map<MVertex*, double>::iterator s1 = _sizes.find(v1);
      if (s0->second < s1->second)s1->second = std::min(s1->second,_beta*s0->second);
      else s0->second = std::min(s0->second,_beta*s1->second);
    }
  }
} 
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20151225/1dcae4f4/attachment.html>