0031842: Coding Rules, BOPAlgo - eliminate CLang warning -fsanitize=undefined referen...
authorkgv <kgv@opencascade.com>
Mon, 12 Oct 2020 15:00:22 +0000 (18:00 +0300)
committerbugmaster <bugmaster@opencascade.com>
Tue, 13 Oct 2020 16:07:42 +0000 (19:07 +0300)
Added NULL checks before Progress Scope pointer dereference.

15 files changed:
src/BOPAlgo/BOPAlgo_BOP.cxx
src/BOPAlgo/BOPAlgo_Builder.cxx
src/BOPAlgo/BOPAlgo_Builder_2.cxx
src/BOPAlgo/BOPAlgo_Builder_3.cxx
src/BOPAlgo/BOPAlgo_CheckerSI.cxx
src/BOPAlgo/BOPAlgo_MakerVolume.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_2.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_4.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx
src/BOPAlgo/BOPAlgo_Splitter.cxx
src/BRepAlgoAPI/BRepAlgoAPI_BuilderAlgo.cxx
src/BRepAlgoAPI/BRepAlgoAPI_Check.cxx

index b516015..b3367e2 100644 (file)
@@ -387,7 +387,10 @@ void BOPAlgo_BOP::Perform()
   pPF=new BOPAlgo_PaveFiller(aAllocator);
   pPF->SetArguments(aLS);
   pPF->SetRunParallel(myRunParallel);
-  pPF->SetProgressIndicator(*myProgressScope);
+  if (myProgressScope != NULL)
+  {
+    pPF->SetProgressIndicator(*myProgressScope);
+  }
   pPF->SetFuzzyValue(myFuzzyValue);
   pPF->SetNonDestructive(myNonDestructive);
   pPF->SetGlue(myGlue);
index e46106e..7ef864a 100644 (file)
@@ -195,7 +195,10 @@ void BOPAlgo_Builder::Perform()
   //
   pPF->SetArguments(myArguments);
   pPF->SetRunParallel(myRunParallel);
-  pPF->SetProgressIndicator(*myProgressScope);
+  if (myProgressScope != NULL)
+  {
+    pPF->SetProgressIndicator(*myProgressScope);
+  }
   pPF->SetFuzzyValue(myFuzzyValue);
   pPF->SetNonDestructive(myNonDestructive);
   pPF->SetGlue(myGlue);
@@ -632,7 +635,10 @@ void BOPAlgo_Builder::BuildBOP(const TopTools_ListOfShape& theObjects,
   aBS.SetRunParallel(myRunParallel);
   aBS.SetContext(myContext);
   aBS.SetFuzzyValue(myFuzzyValue);
-  aBS.SetProgressIndicator(*myProgressScope);
+  if (myProgressScope != NULL)
+  {
+    aBS.SetProgressIndicator(*myProgressScope);
+  }
   aBS.Perform();
 
   // Resulting solids
index 09a57fa..a0a2fc8 100644 (file)
@@ -450,7 +450,10 @@ void BOPAlgo_Builder::BuildSplitFaces()
     aBF.SetFace(aF);
     aBF.SetShapes(aLE);
     aBF.SetRunParallel(myRunParallel);
-    aBF.SetProgressIndicator(*myProgressScope);
+    if (myProgressScope != NULL)
+    {
+      aBF.SetProgressIndicator(*myProgressScope);
+    }
     //
   }// for (i=0; i<aNbS; ++i) {
   //
@@ -637,7 +640,10 @@ void BOPAlgo_Builder::FillSameDomainFaces()
         aPSB.Shape1() = aF1;
         aPSB.Shape2() = aF2;
         aPSB.SetFuzzyValue(myFuzzyValue);
-        aPSB.SetProgressIndicator(*myProgressScope);
+        if (myProgressScope != NULL)
+        {
+          aPSB.SetProgressIndicator(*myProgressScope);
+        }
       }
     }
   }
@@ -790,7 +796,10 @@ void BOPAlgo_Builder::FillInternalVertices()
         aVFI.SetVertex(aV);
         aVFI.SetFace(aFIm);
         aVFI.SetFuzzyValue(myFuzzyValue);
-        aVFI.SetProgressIndicator(*myProgressScope);
+        if (myProgressScope != NULL)
+        {
+          aVFI.SetProgressIndicator(*myProgressScope);
+        }
       }
     }
   }
index 067256a..f8d5b50 100644 (file)
@@ -432,7 +432,10 @@ void BOPAlgo_Builder::BuildSplitSolids(TopTools_DataMapOfShapeShape& theDraftSol
     aBS.SetSolid(aSolid);
     aBS.SetShapes(aSFS);
     aBS.SetRunParallel(myRunParallel);
-    aBS.SetProgressIndicator(*myProgressScope);
+    if (myProgressScope != NULL)
+    {
+      aBS.SetProgressIndicator(*myProgressScope);
+    }
   }//for (i=0; i<aNbS; ++i) {
   //
   Standard_Integer k, aNbBS;
index 26c04b1..93e4a06 100644 (file)
@@ -432,7 +432,10 @@ void BOPAlgo_CheckerSI::CheckFaceSelfIntersection()
     aFaceSelfIntersect.SetFace(aF);
     aFaceSelfIntersect.SetTolF(aTolF);
     //
-    aFaceSelfIntersect.SetProgressIndicator(*myProgressScope);
+    if (myProgressScope != NULL)
+    {
+      aFaceSelfIntersect.SetProgressIndicator(*myProgressScope);
+    }
   }
   
   Standard_Integer aNbFace = aVFace.Length();
index 148046e..2ea86e8 100644 (file)
@@ -86,7 +86,10 @@ void BOPAlgo_MakerVolume::Perform()
   }
   //
   pPF->SetRunParallel(myRunParallel);
-  pPF->SetProgressIndicator(*myProgressScope);
+  if (myProgressScope != NULL)
+  {
+    pPF->SetProgressIndicator(*myProgressScope);
+  }
   pPF->SetFuzzyValue(myFuzzyValue);
   pPF->SetNonDestructive(myNonDestructive);
   pPF->SetGlue(myGlue);
index 5935576..ee6b573 100644 (file)
@@ -264,7 +264,10 @@ void BOPAlgo_PaveFiller::IntersectVE
       aVESolver.SetEdge(aE);
       aVESolver.SetPaveBlock(aPB);
       aVESolver.SetFuzzyValue(myFuzzyValue);
-      aVESolver.SetProgressIndicator(*myProgressScope);
+      if (myProgressScope != NULL)
+      {
+        aVESolver.SetProgressIndicator(*myProgressScope);
+      }
     }
   }
   //
index a100b82..c199a87 100644 (file)
@@ -253,7 +253,10 @@ void BOPAlgo_PaveFiller::PerformEE()
         anEdgeEdge.SetEdge2(aE2, aT21, aT22);
         anEdgeEdge.SetBoxes (aBB1, aBB2);
         anEdgeEdge.SetFuzzyValue(myFuzzyValue);
-        anEdgeEdge.SetProgressIndicator(*myProgressScope);
+        if (myProgressScope != NULL)
+        {
+          anEdgeEdge.SetProgressIndicator(*myProgressScope);
+        }
       }//for (; aIt2.More(); aIt2.Next()) {
     }//for (; aIt1.More(); aIt1.Next()) {
   }//for (; myIterator->More(); myIterator->Next()) {
@@ -1070,10 +1073,17 @@ void BOPAlgo_PaveFiller::ForceInterfEE()
         anEdgeEdge.SetEdge2(aE2, aT21, aT22);
         anEdgeEdge.SetBoxes (myDS->ShapeInfo(nE1).Box(), myDS->ShapeInfo (nE2).Box());
         if (bUseAddTol)
+        {
           anEdgeEdge.SetFuzzyValue(myFuzzyValue + aTolAdd);
+        }
         else
+        {
           anEdgeEdge.SetFuzzyValue(myFuzzyValue);
-        anEdgeEdge.SetProgressIndicator(*myProgressScope);
+        }
+        if (myProgressScope != NULL)
+        {
+          anEdgeEdge.SetProgressIndicator(*myProgressScope);
+        }
       }
     }
   }
index e794d63..9a289dd 100644 (file)
@@ -217,7 +217,10 @@ void BOPAlgo_PaveFiller::PerformVF()
     aVertexFace.SetVertex(aV);
     aVertexFace.SetFace(aF);
     aVertexFace.SetFuzzyValue(myFuzzyValue);
-    aVertexFace.SetProgressIndicator(*myProgressScope);
+    if (myProgressScope != NULL)
+    {
+      aVertexFace.SetProgressIndicator(*myProgressScope);
+    }
   }//for (; myIterator->More(); myIterator->Next()) {
   //
   aNbVF=aVVF.Length();
index 550744b..aebd488 100644 (file)
@@ -278,7 +278,10 @@ void BOPAlgo_PaveFiller::PerformEF()
       aSR = aPBRange;
       BOPTools_AlgoTools::CorrectRange(aE, aF, aSR, aPBRange);
       aEdgeFace.SetRange (aPBRange);
-      aEdgeFace.SetProgressIndicator(*myProgressScope);
+      if (myProgressScope != NULL)
+      {
+        aEdgeFace.SetProgressIndicator(*myProgressScope);
+      }
       // Save the pair to avoid their forced intersection
       BOPDS_MapOfPaveBlock* pMPB = myFPBDone.ChangeSeek(nF);
       if (!pMPB)
@@ -1010,7 +1013,10 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const BOPDS_IndexedMapOfPaveBlock& theMPB
         aEdgeFace.SetFuzzyValue(myFuzzyValue + aTolAdd);
         aEdgeFace.UseQuickCoincidenceCheck(Standard_True);
         aEdgeFace.SetRange(IntTools_Range(aPB->Pave1().Parameter(), aPB->Pave2().Parameter()));
-        aEdgeFace.SetProgressIndicator(*myProgressScope);
+        if (myProgressScope != NULL)
+        {
+          aEdgeFace.SetProgressIndicator(*myProgressScope);
+        }
       }
     }
   }
index 3d6d029..9c35a81 100644 (file)
@@ -308,7 +308,10 @@ void BOPAlgo_PaveFiller::PerformFF()
       //
       aFaceFace.SetParameters(bApprox, bCompC2D1, bCompC2D2, anApproxTol);
       aFaceFace.SetFuzzyValue(myFuzzyValue);
-      aFaceFace.SetProgressIndicator(*myProgressScope);
+      if (myProgressScope != NULL)
+      {
+        aFaceFace.SetProgressIndicator(*myProgressScope);
+      }
     }
     else {
       // for the Glue mode just add all interferences of that type
@@ -1019,7 +1022,10 @@ void BOPAlgo_PaveFiller::PostTreatFF
   }
   //
   // 2 Fuse shapes
-  aPF.SetProgressIndicator(*myProgressScope);
+  if (myProgressScope != NULL)
+  {
+    aPF.SetProgressIndicator(*myProgressScope);
+  }
   aPF.SetRunParallel(myRunParallel);
   aPF.SetArguments(aLS);
   aPF.Perform();
index 18467d0..11a0cac 100644 (file)
@@ -484,7 +484,10 @@ void BOPAlgo_PaveFiller::MakeSplitEdges()
         aBSE.SetCommonBlock(aCB);
       }
       aBSE.SetDS(myDS);
-      aBSE.SetProgressIndicator(*myProgressScope);
+      if (myProgressScope != NULL)
+      {
+        aBSE.SetProgressIndicator(*myProgressScope);
+      }
     } // for (; aItPB.More(); aItPB.Next()) {
   }  // for (i=0; i<aNbPBP; ++i) {      
   //
@@ -596,7 +599,10 @@ void BOPAlgo_PaveFiller::MakePCurves()
       BOPAlgo_MPC& aMPC=aVMPC.Appended();
       aMPC.SetEdge(aE);
       aMPC.SetFace(aF1F);
-      aMPC.SetProgressIndicator(*myProgressScope);
+      if (myProgressScope != NULL)
+      {
+        aMPC.SetProgressIndicator(*myProgressScope);
+      }
     }
     //
     // On
@@ -660,7 +666,10 @@ void BOPAlgo_PaveFiller::MakePCurves()
 
       aMPC.SetEdge(aE);
       aMPC.SetFace(aF1F);
-      aMPC.SetProgressIndicator(*myProgressScope);
+      if (myProgressScope != NULL)
+      {
+        aMPC.SetProgressIndicator(*myProgressScope);
+      }
     }
   }// for (i=0; i<aNbFI; ++i) {
   //
@@ -710,7 +719,10 @@ void BOPAlgo_PaveFiller::MakePCurves()
               aMPC.SetEdge(aE);
               aMPC.SetFace(aFf[m]);
               aMPC.SetFlag(Standard_True);
-              aMPC.SetProgressIndicator(*myProgressScope);
+              if (myProgressScope != NULL)
+              {
+                aMPC.SetProgressIndicator(*myProgressScope);
+              }
             }
           }
         }
index 5936d6c..dc53bef 100644 (file)
@@ -89,7 +89,10 @@ void BOPAlgo_Splitter::Perform()
   BOPAlgo_PaveFiller *pPF = new BOPAlgo_PaveFiller();
   pPF->SetArguments(aLS);
   pPF->SetRunParallel(myRunParallel);
-  pPF->SetProgressIndicator(*myProgressScope);
+  if (myProgressScope != NULL)
+  {
+    pPF->SetProgressIndicator(*myProgressScope);
+  }
   pPF->SetFuzzyValue(myFuzzyValue);
   pPF->SetNonDestructive(myNonDestructive);
   pPF->SetGlue(myGlue);
index 0046e4f..4e310b2 100644 (file)
@@ -125,7 +125,10 @@ void BRepAlgoAPI_BuilderAlgo::IntersectShapes(const TopTools_ListOfShape& theArg
   myDSFiller->SetArguments(theArgs);
   // Set options for intersection
   myDSFiller->SetRunParallel(myRunParallel);
-  myDSFiller->SetProgressIndicator(*myProgressScope);
+  if (myProgressScope != NULL)
+  {
+    myDSFiller->SetProgressIndicator(*myProgressScope);
+  }
   myDSFiller->SetFuzzyValue(myFuzzyValue);
   myDSFiller->SetNonDestructive(myNonDestructive);
   myDSFiller->SetGlue(myGlue);
@@ -145,7 +148,10 @@ void BRepAlgoAPI_BuilderAlgo::BuildResult()
 {
   // Set options to the builder
   myBuilder->SetRunParallel(myRunParallel);
-  myBuilder->SetProgressIndicator(*myProgressScope);
+  if (myProgressScope != NULL)
+  {
+    myBuilder->SetProgressIndicator(*myProgressScope);
+  }
   myBuilder->SetCheckInverted(myCheckInverted);
   myBuilder->SetToFillHistory(myFillHistory);
   // Perform building of the result with pre-calculated intersections
index d906ff2..3dc0098 100644 (file)
@@ -94,7 +94,10 @@ void BRepAlgoAPI_Check::Perform()
   anAnalyzer.SelfInterMode() = myTestSI;
   // Set options from BOPAlgo_Options
   anAnalyzer.SetRunParallel(myRunParallel);
-  anAnalyzer.SetProgressIndicator(*myProgressScope);
+  if (myProgressScope != NULL)
+  {
+    anAnalyzer.SetProgressIndicator(*myProgressScope);
+  }
   anAnalyzer.SetFuzzyValue(myFuzzyValue);
   // Perform the check
   anAnalyzer.Perform();