From: azv Date: Fri, 25 Dec 2015 07:15:17 +0000 (+0300) Subject: Fix crash when walking out of array boundaries (issue #1178) X-Git-Tag: V_2.1.0~55 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ef16991ed2c132b5b447529a59cda52a508251c8;p=modules%2Fshaper.git Fix crash when walking out of array boundaries (issue #1178) --- diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Solver.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Solver.cpp index a7a83a13d..b2a475f23 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Solver.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Solver.cpp @@ -155,6 +155,10 @@ bool SolveSpaceSolver_Solver::hasDegeneratedArcs() const const int aShift = anEntity.point[aPnt] - anEntity.h; int aPntInd = anEnt + aShift; int aStep = 1; + if (aPntInd < 0) + aPntInd = 0; + else if (aPntInd >= myEquationsSystem.entities) + aPntInd = myEquationsSystem.entities - 1; if (myEquationsSystem.entity[aPntInd].h > anEntity.point[aPnt]) aStep = -1; for (; aPntInd >=0 && aPntInd < myEquationsSystem.entities; aPntInd += aStep) diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp index 681c96c57..7a185c8af 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp @@ -278,7 +278,7 @@ void SolveSpaceSolver_Storage::addCoincidentPoints( // Search available coincidence CoincidentPointsMap::iterator aMasterFound = myCoincidentPoints.find(theMaster); CoincidentPointsMap::iterator aSlaveFound = myCoincidentPoints.find(theSlave); - if (aMasterFound == myCoincidentPoints.end() && aSlaveFound == myCoincidentPoints.end()) { + if (aMasterFound == myCoincidentPoints.end() || aSlaveFound == myCoincidentPoints.end()) { // try to find master and slave points in the lists of slaves of already existent coincidences CoincidentPointsMap::iterator anIt = myCoincidentPoints.begin(); for (; anIt != myCoincidentPoints.end(); ++anIt) {