]> OCCT Git - occt.git/commitdiff
0033048: Foundation Classes - math_ComputeKronrodPointsAndWeights indexation goes...
authoraml <aml@opencascade.com>
Mon, 4 Jul 2022 09:41:15 +0000 (12:41 +0300)
committersmoskvin <smoskvin@opencascade.com>
Wed, 6 Jul 2022 16:16:55 +0000 (19:16 +0300)
Add test and explanatory comment.

src/QABugs/QABugs_20.cxx
src/math/math_ComputeKronrodPointsAndWeights.cxx
tests/bugs/fclasses/bug33048 [new file with mode: 0644]

index a70b333fdfcb1da3ff89546d026c1b4c6f44ff9f..8a5443f1399dd78ca845312dcf80c35b84a75a1c 100644 (file)
@@ -65,6 +65,7 @@
 #include <OSD_Timer.hxx>
 #include <TDataStd_Name.hxx>
 #include <AppCont_Function.hxx>
+#include <math_ComputeKronrodPointsAndWeights.hxx>
 
 #include <limits>
 
@@ -4261,6 +4262,28 @@ static Standard_Integer OCC33009(Draw_Interpretor&, Standard_Integer, const char
   return 0;
 }
 
+static Standard_Integer OCC33048(Draw_Interpretor&, Standard_Integer, const char**)
+{
+  Standard_Real isOK = true;
+  try
+  {
+    // This method uses raw pointers for memory manipulations and not used in OCCT.
+    math_ComputeKronrodPointsAndWeights aCalc(125);
+    isOK = aCalc.IsDone();
+  }
+  catch (...)
+  {
+    isOK = false;
+  }
+
+  if (isOK)
+    std::cout << "OK: Kronrod points and weights are calculated successfully." << std::endl;
+  else
+    std::cout << "Error: Problem occurred during calculation of Kronrod points and weights." << std::endl;
+
+  return 0;
+}
+
 //=======================================================================
 //function : QACheckBends
 //purpose :
@@ -4435,6 +4458,10 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
                  "Tests the case when", 
                  __FILE__, OCC33009, group);
 
+  theCommands.Add("OCC33048",
+                 "Kronrod points and weights calculation", 
+                 __FILE__, OCC33048, group);
+
   theCommands.Add("QACheckBends",
     "QACheckBends curve [CosMaxAngle [theNbPoints]]",
     __FILE__,
index d8e1188e6d58ffdf5b926ea869083e93f5c41321..339dc85f94949960ffc2a97ea6ddc0cf849d9952 100644 (file)
@@ -54,7 +54,10 @@ math_ComputeKronrodPointsAndWeights::math_ComputeKronrodPointsAndWeights(const S
       aSubDiag(i) = 0.;
     }
   
-    // Initialization of temporary data structures.
+    // Algorithm calculates weights and points symmetrically and uses -1 index
+    // by design. Memory corruption is avoided by moving pointer `s` to the 
+    // next element and saving original pointer into `ss` for the proper memory
+    // releasing. Similarly, `t` and `tt` are addressed.
     Standard_Integer  aNd2 =     Number/2;
     Standard_Real    *s    = new Standard_Real[aNd2 + 2];
     Standard_Real    *t    = new Standard_Real[aNd2 + 2];
diff --git a/tests/bugs/fclasses/bug33048 b/tests/bugs/fclasses/bug33048
new file mode 100644 (file)
index 0000000..d47f4c9
--- /dev/null
@@ -0,0 +1,9 @@
+puts "============"
+puts "0033048: Foundation Classes - math_ComputeKronrodPointsAndWeights indexation go beyond the limit"
+puts "============"
+puts ""
+
+cpulimit 30
+
+pload QAcommands
+OCC33048