From ef16991ed2c132b5b447529a59cda52a508251c8 Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 25 Dec 2015 10:15:17 +0300 Subject: [PATCH] Fix crash when walking out of array boundaries (issue #1178) --- src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Solver.cpp | 4 ++++ .../SolveSpaceSolver/SolveSpaceSolver_Storage.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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) { -- 2.39.2