From 255b09d20675f1003a77b07fac9a837a7f47bf6e Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 2 Dec 2009 17:22:10 +0300 Subject: [PATCH] guard against infinite loop when expanding live template (IDEADEV-41789) [r=max] --- .../com/intellij/codeInsight/template/impl/TemplateState.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java index 896945df10a0..fa3932580e17 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java @@ -536,8 +536,10 @@ public class TemplateState implements Disposable { new Runnable() { public void run() { BitSet calcedSegments = new BitSet(); + int maxAttempts = (myTemplate.getVariableCount()+1)*3; do { + maxAttempts--; calcedSegments.clear(); for (int i = myCurrentVariableNumber + 1; i < myTemplate.getVariableCount(); i++) { String variableName = myTemplate.getVariableNameAt(i); @@ -565,7 +567,7 @@ public class TemplateState implements Disposable { } } } - while (!calcedSegments.isEmpty()); + while (!calcedSegments.isEmpty() && maxAttempts >= 0); } } );