From 7a3fcc5fb01cab06296a425dcb3a4cf9b21b8038 Mon Sep 17 00:00:00 2001 From: ageay Date: Mon, 3 Jan 2011 14:19:48 +0000 Subject: [PATCH] Protection of insertNextCell --- src/MEDCoupling/MEDCouplingUMesh.cxx | 5 +++++ 1 file changed, 5 insertions(+) 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]; -- 2.39.2