From ae96acd2d1db0cb0ce8eead22a829bd63aa1105b Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 29 Oct 2018 15:47:25 +0300 Subject: [PATCH] Issue #2727: Avoid unlimited loop in sorting --- src/ModuleBase/ModuleBase_ITreeNode.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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; } } } -- 2.39.2