From cf2565fe3fe0313f2b373cdd72e8c1aa19250d08 Mon Sep 17 00:00:00 2001 From: ageay Date: Wed, 8 Feb 2012 15:54:58 +0000 Subject: [PATCH] Some protection on buildPartOfmyself method. --- src/MEDCoupling/MEDCouplingUMesh.cxx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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; } -- 2.39.2