0029939: Modeling Algorithms - add NULL check to BRepGProp_Face::Load()
[occt.git] / src / BRepGProp / BRepGProp_Gauss.cxx
index e8d70b1..0ce6ff1 100644 (file)
@@ -625,7 +625,10 @@ Standard_Real BRepGProp_Gauss::Compute(
     }
     else
     {
-      theSurface.Load(theDomain.Value());
+      if (!theSurface.Load(theDomain.Value()))
+      {
+        return Precision::Infinite();
+      }
       NbLGaussP[0] = theSurface.LIntOrder(anEpsilon);
     }
 
@@ -1116,9 +1119,12 @@ void BRepGProp_Gauss::Compute(BRepGProp_Face&   theSurface,
   math::GaussWeights(NbGaussgp_Pnts, GaussSWV);
 
   BRepGProp_Gauss::Inertia anInertia;
-  while (theDomain.More())
+  for (; theDomain.More(); theDomain.Next())
   {
-    theSurface.Load(theDomain.Value());
+    if (!theSurface.Load(theDomain.Value()))
+    {
+      return;
+    }
 
     Standard_Integer NbCGaussgp_Pnts =
       Min(theSurface.IntegrationOrder(), math::GaussPointsMax());
@@ -1171,8 +1177,6 @@ void BRepGProp_Gauss::Compute(BRepGProp_Face&   theSurface,
 
     multAndRestoreInertia(lr, aCInertia);
     addAndRestoreInertia (aCInertia, anInertia);
-
-    theDomain.Next();
   }
 
   convert(anInertia, theOutGravityCenter, theOutInertia, theOutMass);
@@ -1200,9 +1204,12 @@ void BRepGProp_Gauss::Compute(BRepGProp_Face&         theSurface,
   Standard_Real _u2 = u2;  //OCC104
 
   BRepGProp_Gauss::Inertia anInertia;
-  while (theDomain.More())
+  for (; theDomain.More(); theDomain.Next())
   {
-    theSurface.Load(theDomain.Value());
+    if (!theSurface.Load(theDomain.Value()))
+    {
+      return;
+    }
 
     const Standard_Integer aVNbCGaussgp_Pnts =
       theSurface.VIntegrationOrder();
@@ -1265,8 +1272,6 @@ void BRepGProp_Gauss::Compute(BRepGProp_Face&         theSurface,
 
     multAndRestoreInertia(lr,        aCInertia);
     addAndRestoreInertia (aCInertia, anInertia);
-
-    theDomain.Next();
   }
 
   convert(anInertia, theCoeff, theIsByPoint, theOutGravityCenter, theOutInertia, theOutMass);