From 659e3364ce2c6e725e9dac75feb6ec778ee1a8bc Mon Sep 17 00:00:00 2001 From: ageay Date: Mon, 19 Aug 2013 10:55:11 +0000 Subject: [PATCH] Protection against sigsegv using DataArrayInt::invertArrayO2N2N2O in case on invalid input. --- src/MEDCoupling/MEDCouplingMemArray.cxx | 30 +++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 9c2fda8fa..92777b419 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -6202,8 +6202,19 @@ DataArrayInt *DataArrayInt::invertArrayO2N2N2O(int newNbOfElem) const const int *old2New=getConstPointer(); int *pt=ret->getPointer(); for(int i=0;i!=nbOfOldNodes;i++) - if(old2New[i]!=-1) - pt[old2New[i]]=i; + { + int newp(old2New[i]); + if(newp!=-1) + { + if(newp>=0 && newpgetPointer(); for(int i=nbOfOldNodes-1;i>=0;i--) - if(old2New[i]!=-1) - pt[old2New[i]]=i; + { + int newp(old2New[i]); + if(newp!=-1) + { + if(newp>=0 && newp