From 1911ccc55cfa86b832fa1ccf021292b34e189b8c Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Thu, 10 Dec 2020 22:37:42 +0300 Subject: [PATCH] Issue #20476: sigsegv with offset Crash in Offset algorithm has been eliminated. --- src/SketchPlugin/SketchPlugin_Offset.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/SketchPlugin/SketchPlugin_Offset.cpp b/src/SketchPlugin/SketchPlugin_Offset.cpp index 4400e8e61..0412143d0 100644 --- a/src/SketchPlugin/SketchPlugin_Offset.cpp +++ b/src/SketchPlugin/SketchPlugin_Offset.cpp @@ -192,10 +192,15 @@ void SketchPlugin_Offset::execute() std::shared_ptr anOffsetShape( new GeomAlgoAPI_Offset(aPlane, aWireShape, aValue*aSign)); - std::shared_ptr aMakeList(new GeomAlgoAPI_MakeShapeList); - aMakeList->appendAlgo(aWireBuilder); - aMakeList->appendAlgo(anOffsetShape); - anOffsetAlgos.push_back(aMakeList); + if (anOffsetShape->isDone()) { + std::shared_ptr 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::iterator anIt = aWeights.begin(); - for (int anIndex = 0; anIt != aWeights.end(); ++anIt, ++anIndex) - aWeightsAttr->setValue(anIndex, *anIt); + std::list::iterator aWIt = aWeights.begin(); + for (int anIndex = 0; aWIt != aWeights.end(); ++aWIt, ++anIndex) + aWeightsAttr->setValue(anIndex, *aWIt); } AttributeDoubleArrayPtr aKnotsAttr = -- 2.39.2