]> OCCT Git - occt.git/commitdiff
0033603: Data Exchange, Step Import - Crash reading corrupted STEP file
authorichesnok <ichesnok@opencascade.com>
Mon, 11 Mar 2024 10:13:34 +0000 (10:13 +0000)
committervglukhik <vglukhik@opencascade.com>
Sat, 16 Mar 2024 19:35:48 +0000 (19:35 +0000)
Crash fixed by checking IsNull().

src/StepToGeom/StepToGeom.cxx
src/StepToTopoDS/StepToTopoDS_TranslateVertex.cxx

index 084531d8f08fcb3d70e385bcadb658dcd4b0c36e..e15afe880debe0da8b24e302d9a887ccf09012ec 100644 (file)
@@ -1008,7 +1008,7 @@ Handle(Geom_BSplineSurface) StepToGeom::MakeBSplineSurface (const Handle(StepGeo
 Handle(Geom_CartesianPoint) StepToGeom::MakeCartesianPoint (const Handle(StepGeom_CartesianPoint)& SP,
                                                             const StepData_Factors& theLocalFactors)
 {
-  if (SP->NbCoordinates() == 3)
+  if (!SP.IsNull() && SP->NbCoordinates() == 3)
   {
     const Standard_Real LF = theLocalFactors.LengthFactor();
     const Standard_Real X = SP->CoordinatesValue(1) * LF;
index b9ae793360f03f90c2f27645c3d48fede00de6e6..793063c6c4a34a9ab69ac6180bcbaad3edc6a71e 100644 (file)
@@ -96,6 +96,11 @@ void StepToTopoDS_TranslateVertex::Init(const Handle(StepShape_Vertex)& aVertex,
 //:S4136    Standard_Real preci = BRepAPI::Precision();
     const Handle(StepShape_VertexPoint) VP = Handle(StepShape_VertexPoint)::DownCast(aVertex);
     const Handle(StepGeom_Point) P = VP->VertexGeometry();
+    if (P.IsNull()) {
+      myError = StepToTopoDS_TranslateVertexOther;
+      done = Standard_False;
+      return;
+    }
     const Handle(StepGeom_CartesianPoint) P1 = Handle(StepGeom_CartesianPoint)::DownCast(P);
     Handle(Geom_CartesianPoint) P2 = StepToGeom::MakeCartesianPoint (P1, theLocalFactors);
     BRep_Builder B;