]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
PAL13117: Bug in RemoveObject method.
authorjfa <jfa@opencascade.com>
Thu, 3 Aug 2006 11:17:55 +0000 (11:17 +0000)
committerjfa <jfa@opencascade.com>
Thu, 3 Aug 2006 11:17:55 +0000 (11:17 +0000)
src/GEOMImpl/GEOMImpl_IGroupOperations.cxx

index 3bc83464cbabe16013a88eeda44d21f794429617..7535fd4075aebd31a04b13f103301a064d33d577 100644 (file)
@@ -196,20 +196,18 @@ void GEOMImpl_IGroupOperations::RemoveObject (Handle(GEOM_Object) theGroup, int
     else {
       aNewSeq = new TColStd_HArray1OfInteger(1, aLength-1);
       Standard_Boolean isFound = Standard_False;
-      for(Standard_Integer i = 1, k=1; i<=aLength; i++) {
-       if(i == aLength && !isFound) {
-         SetErrorCode(NOT_EXISTS);
-         return; 
-       }
-       if(aSeq->Value(i) == theSubShapeID) {
+      for (Standard_Integer i = 1, k = 1; i <= aLength; i++) {
+       if (aSeq->Value(i) == theSubShapeID) {
          isFound = Standard_True;
-         continue;
-       }
-       aNewSeq->SetValue(k, aSeq->Value(i));
-       k++;
+       } else {
+          if (k < aLength) { // this check is to avoid sequence <aNewSeq> overflow
+            aNewSeq->SetValue(k, aSeq->Value(i));
+            k++;
+          }
+        }
       }
 
-      if(!isFound) {
+      if (!isFound) {
        SetErrorCode(NOT_EXISTS);
        return; 
       }