From: geay Date: Wed, 14 May 2014 08:29:17 +0000 (+0200) Subject: Protect applyLin against errors in input (bug PAL1164, CEA22584) X-Git-Tag: V7_4_0rc1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=085ee0bf6cf109c710b93884ddb5753cf3d877eb;p=modules%2Fmed.git Protect applyLin against errors in input (bug PAL1164, CEA22584) --- diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 86b8c8727..c54ef2cec 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -4113,14 +4113,18 @@ DataArrayDouble *DataArrayDouble::computeAbs() const * \param [in] a - the first coefficient of the function. * \param [in] b - the second coefficient of the function. * \param [in] compoId - the index of component to modify. - * \throw If \a this is not allocated. + * \throw If \a this is not allocated, or \a compoId is not in [0,\c this->getNumberOfComponents() ). */ void DataArrayDouble::applyLin(double a, double b, int compoId) { checkAllocated(); - double *ptr=getPointer()+compoId; - int nbOfComp=getNumberOfComponents(); - int nbOfTuple=getNumberOfTuples(); + double *ptr(getPointer()+compoId); + int nbOfComp(getNumberOfComponents()),nbOfTuple(getNumberOfTuples()); + if(compoId<0 || compoId>=nbOfComp) + { + std::ostringstream oss; oss << "DataArrayDouble::applyLin : The compoId requested (" << compoId << ") is not valid ! Must be in [0," << nbOfComp << ") !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } for(int i=0;i