Salome HOME
#878 Segmentation fault when setting distance on the two same points
[modules/shaper.git] / src / SketchSolver / SketchSolver_Solver.cpp
index 0e7b1761cc51e62b2aeeede9ce12c1c952d9f51c..4e7a4f0e9269f7e2d76ad8219a130fce099864f3 100644 (file)
@@ -63,8 +63,10 @@ void SketchSolver_Solver::setConstraints(Slvs_Constraint* theConstraints, int th
     myEquationsSystem.constraints = theSize;
   }
   else if (myEquationsSystem.constraints != theSize) {
-    delete[] myEquationsSystem.constraint;
-    myEquationsSystem.constraint = new Slvs_Constraint[theSize];
+    if (theSize > myEquationsSystem.constraints) {
+      delete[] myEquationsSystem.constraint;
+      myEquationsSystem.constraint = new Slvs_Constraint[theSize];
+    }
     myEquationsSystem.constraints = theSize;
   }
   memcpy(myEquationsSystem.constraint, theConstraints, theSize * sizeof(Slvs_Constraint));