]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2727: Avoid unlimited loop in sorting
authorvsv <vsv@opencascade.com>
Mon, 29 Oct 2018 12:47:25 +0000 (15:47 +0300)
committervsv <vsv@opencascade.com>
Mon, 29 Oct 2018 12:47:25 +0000 (15:47 +0300)
src/ModuleBase/ModuleBase_ITreeNode.h

index cef49758a23bc02fe4bc26c59943d222f697c483..33b8d8a6450dcf922a08a571b33d391971a36f77 100644 (file)
@@ -185,9 +185,14 @@ protected:
       int aIdx;
       int aCount = 0;
       int aSize = myChildren.size();
+      int aMaxCount = aSize * aSize;
       int aShift = 0;
       while (i < aSize) {
         aCount++;
+        // To avoid unlimited cycling
+        if (aCount > aMaxCount)
+          break;
+
         aNode = myChildren.at(i);
         aObject = aNode->object();
         if (aObject.get()) {
@@ -202,9 +207,6 @@ protected:
         else
           aShift++;
         i++;
-        // To avoid unlimited cycling
-        if (aCount > aSize * aSize)
-          break;
       }
     }
   }