From: ageay Date: Wed, 8 Feb 2012 15:54:58 +0000 (+0000) Subject: Some protection on buildPartOfmyself method. X-Git-Tag: V6_main_FINAL~879 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cf2565fe3fe0313f2b373cdd72e8c1aa19250d08;p=tools%2Fmedcoupling.git Some protection on buildPartOfmyself method. --- diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index a678eb5c3..822c1140c 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -2084,7 +2084,8 @@ void MEDCouplingUMesh::unserialization(const std::vector& tinyInfoD, con MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *begin, const int *end) const { checkFullyDefined(); - MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); + int ncell=getNumberOfCells(); + MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingUMesh::New(); ret->_mesh_dim=_mesh_dim; ret->setCoords(_coords); std::size_t nbOfElemsRet=std::distance(begin,end); @@ -2094,7 +2095,16 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *begin const int *connIndex=_nodal_connec_index->getConstPointer(); int newNbring=0; for(const int *work=begin;work!=end;work++,newNbring++) - connIndexRet[newNbring+1]=connIndexRet[newNbring]+connIndex[*work+1]-connIndex[*work]; + { + if(*work>=0 && *work types; @@ -2123,6 +2133,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *begin } else ret->setName(getName()); + ret->incrRef(); return ret; }