Salome HOME
Issue #20476: sigsegv with offset
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Thu, 10 Dec 2020 19:37:42 +0000 (22:37 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Thu, 10 Dec 2020 19:38:38 +0000 (22:38 +0300)
Crash in Offset algorithm has been eliminated.

src/SketchPlugin/SketchPlugin_Offset.cpp

index 4400e8e612ec3dab39301459019861d2b9712cdc..0412143d037fc9226cf57ac585c0565b3029c6ea 100644 (file)
@@ -192,10 +192,15 @@ void SketchPlugin_Offset::execute()
       std::shared_ptr<GeomAlgoAPI_Offset> anOffsetShape(
           new GeomAlgoAPI_Offset(aPlane, aWireShape, aValue*aSign));
 
-      std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeList(new GeomAlgoAPI_MakeShapeList);
-      aMakeList->appendAlgo(aWireBuilder);
-      aMakeList->appendAlgo(anOffsetShape);
-      anOffsetAlgos.push_back(aMakeList);
+      if (anOffsetShape->isDone()) {
+        std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeList(new GeomAlgoAPI_MakeShapeList);
+        aMakeList->appendAlgo(aWireBuilder);
+        aMakeList->appendAlgo(anOffsetShape);
+        anOffsetAlgos.push_back(aMakeList);
+      }
+      else {
+        setError("Offset algorithm failed");
+      }
     }
   }
 
@@ -633,9 +638,9 @@ void SketchPlugin_Offset::mkBSpline (FeaturePtr& theResult,
   }
   else { // non-rational B-spline
     aWeightsAttr->setSize((int)aWeights.size());
-    std::list<double>::iterator anIt = aWeights.begin();
-    for (int anIndex = 0; anIt != aWeights.end(); ++anIt, ++anIndex)
-      aWeightsAttr->setValue(anIndex, *anIt);
+    std::list<double>::iterator aWIt = aWeights.begin();
+    for (int anIndex = 0; aWIt != aWeights.end(); ++aWIt, ++anIndex)
+      aWeightsAttr->setValue(anIndex, *aWIt);
   }
 
   AttributeDoubleArrayPtr aKnotsAttr =