From: vsv Date: Mon, 29 Oct 2018 12:47:25 +0000 (+0300) Subject: Issue #2727: Avoid unlimited loop in sorting X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e89750518a93cd94bd897ad2837fb29d4d266f16;p=modules%2Fshaper.git Issue #2727: Avoid unlimited loop in sorting --- diff --git a/src/ModuleBase/ModuleBase_ITreeNode.h b/src/ModuleBase/ModuleBase_ITreeNode.h index cef49758a..33b8d8a64 100644 --- a/src/ModuleBase/ModuleBase_ITreeNode.h +++ b/src/ModuleBase/ModuleBase_ITreeNode.h @@ -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; } } }