0024919: ShapeFix can crash time-to-time due to inproper interator handling inside...
authorrazmyslovich <razmyslovich@volumegraphics.com>
Wed, 14 May 2014 10:28:15 +0000 (12:28 +0200)
committerapn <apn@opencascade.com>
Thu, 22 May 2014 12:56:19 +0000 (16:56 +0400)
Check inter variable to be inside of the desired range

src/Approx/Approx_SameParameter.cxx

index 3fc41f3..3589ae0 100644 (file)
@@ -451,10 +451,10 @@ void Approx_SameParameter::Build(const Standard_Real Tolerance)
     ii =1;
     new_par.Append(fcons);
 
-    while(Param_de_decoupeC1(inter) <= fcons + deltamin) inter++;
-    while(Param_de_decoupeC1(NbInt) >= lcons - deltamin) NbInt--;
+    while(inter <= NbInt && Param_de_decoupeC1(inter) <= fcons + deltamin) inter++;
+    while(NbInt > 0 && Param_de_decoupeC1(NbInt) >= lcons - deltamin) NbInt--;
 
-    while(inter <= NbInt || ii < NCONTROL) {
+    while(inter <= NbInt || (ii < NCONTROL && inter <= Param_de_decoupeC1.Length()) ) {
       if(Param_de_decoupeC1(inter) < pcons[ii]) {
         new_par.Append(Param_de_decoupeC1(inter));
         if((pcons[ii] - Param_de_decoupeC1(inter)) <= deltamin) {