From cd052ee5de51bfd331c17cf21936f563ff9b3eab Mon Sep 17 00:00:00 2001 From: Oleg Krasilnikov Date: Wed, 21 Jun 2006 11:50:10 +0000 Subject: [PATCH] [Bug 148003] [New Class Wizard] Browse for Folder can cause infinite loop Problem reason: loop inside of NewClassWizardUtil.getSourceFolder(). After "path.removeLastSegments(1)" deletes the last segment, path would contain "\", because (separators & HAS_LEADING) != 0) So, "path.isEmpty()" treats it as root path and returns false. That's why loop became infinite. Fix: - while (!path.isEmpty()) { + while (path.segmentCount() > 0) { --- .../cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java index 7ecbecd9ed6..e73366044aa 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java @@ -82,7 +82,7 @@ public class NewClassWizardUtil { public static ICContainer getSourceFolder(IPath path) { if (path == null) return null; - while (!path.isEmpty()) { + while (path.segmentCount() > 0) { IResource res = getWorkspaceRoot().findMember(path); if (res != null && res.exists()) { int resType = res.getType();