]> OCCT Git - occt-copy.git/commitdiff
0024829: sprops with precision throws an exception
authornbv <nbv@opencascade.com>
Thu, 8 May 2014 07:53:41 +0000 (11:53 +0400)
committernbv <nbv@opencascade.com>
Thu, 19 Jan 2017 14:19:54 +0000 (17:19 +0300)
Reason of exception is reading nonexistent element of array.

Test case for issue CR24829

(cherry picked from commit 6a6946f24e906c3e8efc2b34ddeb9c771bb037d0)

Task GEOM-04-011: negative surface area issue Set-57.

src/GProp/GProp_SGProps.gxx
tests/bugs/modalg_5/bug24829 [new file with mode: 0644]

index 62535d3f7999d9b3456e7f42684bfbc6cb2563b7..8fa67d481698e8550d253d090c0529147ea407b7 100644 (file)
@@ -221,9 +221,9 @@ static Standard_Integer LFillIntervalBounds(Standard_Real               A,
                                             const TColStd_Array1OfReal& Knots, 
                                             const Standard_Integer      NumSubs)
 {
-  Standard_Integer iEnd = Knots.Upper(), jEnd = L1->Upper();
+  Standard_Integer iEnd = MaxSubs(Knots.Upper()-1, NumSubs), jEnd = L1->Upper();
+  iEnd = Max(iEnd, Knots.Upper());
   if(iEnd - 1 > jEnd){
-    iEnd = MaxSubs(iEnd-1,NumSubs); 
     L1    = new math_Vector(1,iEnd);
     L2    = new math_Vector(1,iEnd);
     DimL  = new math_Vector(1,iEnd);
@@ -247,9 +247,9 @@ static Standard_Integer UFillIntervalBounds(Standard_Real               A,
                                             const TColStd_Array1OfReal& Knots, 
                                             const Standard_Integer      NumSubs)
 {
-  Standard_Integer iEnd = Knots.Upper(), jEnd = U1->Upper();
+  Standard_Integer iEnd = MaxSubs(Knots.Upper()-1, NumSubs), jEnd = U1->Upper();
+  iEnd = Max(iEnd, Knots.Upper());
   if(iEnd - 1 > jEnd){
-    iEnd = MaxSubs(iEnd-1,NumSubs); 
     U1   = new math_Vector(1,iEnd);
     U2   = new math_Vector(1,iEnd);
     DimU = new math_Vector(1,iEnd);
diff --git a/tests/bugs/modalg_5/bug24829 b/tests/bugs/modalg_5/bug24829
new file mode 100644 (file)
index 0000000..0400b1d
--- /dev/null
@@ -0,0 +1,15 @@
+puts "========="
+puts "OCC24829"
+puts "========="
+puts ""
+###########################################################
+# sprops with precision throws an exception
+###########################################################
+
+restore [locate_data_file bug24829_faceOutput-wrong.brep] result
+
+sprops result 0.0001
+
+set square 15.1187
+
+set 3dviewer 1