From: vsv Date: Mon, 29 Oct 2018 12:47:25 +0000 (+0300) Subject: Issue #2727: Avoid unlimited loop in sorting X-Git-Tag: End2018~241 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ae96acd2d1db0cb0ce8eead22a829bd63aa1105b;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; } } }