1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0033048: Foundation Classes - math_ComputeKronrodPointsAndWeights indexation goes beyond the limit

Add test and explanatory comment.
This commit is contained in:
aml 2022-07-04 12:41:15 +03:00 committed by smoskvin
parent 3a2ca49b6d
commit c2eed2a326
3 changed files with 40 additions and 1 deletions

View 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__,

View 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];

View File

@ -0,0 +1,9 @@
puts "============"
puts "0033048: Foundation Classes - math_ComputeKronrodPointsAndWeights indexation go beyond the limit"
puts "============"
puts ""
cpulimit 30
pload QAcommands
OCC33048