From: ageay Date: Mon, 3 Jan 2011 14:19:48 +0000 (+0000) Subject: Protection of insertNextCell X-Git-Tag: V6_main_FINAL~1139 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7a3fcc5fb01cab06296a425dcb3a4cf9b21b8038;p=tools%2Fmedcoupling.git Protection of insertNextCell --- diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 9e9040fc3..89ff2811c 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -157,8 +157,13 @@ void MEDCouplingUMesh::allocateCells(int nbOfCells) void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell) throw(INTERP_KERNEL::Exception) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type); + if(_nodal_connec_index==0) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::insertNextCell : nodal connectivity not set ! invoke allocateCells before calling insertNextCell !"); if((int)cm.getDimension()==_mesh_dim) { + int nbOfElems=_nodal_connec_index->getNbOfElems()-1; + if(_iterator>=nbOfElems) + throw INTERP_KERNEL::Exception("MEDCouplingUMesh::insertNextCell : allocation of cells was wide enough ! Call insertNextCell with higher value or call finishInsertingCells !"); int *pt=_nodal_connec_index->getPointer(); int idx=pt[_iterator];