]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Protection of insertNextCell
authorageay <ageay>
Mon, 3 Jan 2011 14:19:48 +0000 (14:19 +0000)
committerageay <ageay>
Mon, 3 Jan 2011 14:19:48 +0000 (14:19 +0000)
src/MEDCoupling/MEDCouplingUMesh.cxx

index 9e9040fc34990b1d6824c6018ccc7aa483f7e107..89ff2811cf1a54bd2f5e3a4bd0e5abacc6684a94 100644 (file)
@@ -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];