From 948ad54c3a77763a43e90c8ced2127c5bcde6094 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Fri, 30 Jun 2006 09:28:30 +0000 Subject: [PATCH] Fix potential endless loops because of path.isEmpty() --- .../browser/org/eclipse/cdt/core/browser/PathUtil.java | 5 +++-- .../utils/org/eclipse/cdt/utils/PathUtil.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/PathUtil.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/PathUtil.java index f1848733bf9..74bfe98a276 100644 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/PathUtil.java +++ b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/PathUtil.java @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.browser; @@ -136,7 +137,7 @@ public class PathUtil { IWorkspaceRoot root = getWorkspaceRoot(); if (root != null) { IPath path = getWorkspaceRelativePath(fullPath); - while (!path.isEmpty()) { + while (path.segmentCount() > 0) { IResource res = root.findMember(path); if (res != null) return CoreModel.getDefault().create(res.getProject()); @@ -151,7 +152,7 @@ public class PathUtil { IWorkspaceRoot root = getWorkspaceRoot(); if (root != null) { IPath path = getWorkspaceRelativePath(fullPath); - while (!path.isEmpty()) { + while (path.segmentCount() > 0) { IResource res = root.findMember(path); if (res != null && res.exists() && (res.getType() == IResource.PROJECT || res.getType() == IResource.FOLDER)) return path; diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/PathUtil.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/PathUtil.java index 547b7688f2d..13ed72371e7 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/PathUtil.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/PathUtil.java @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.utils; @@ -134,7 +135,7 @@ public class PathUtil { IWorkspaceRoot root = getWorkspaceRoot(); if (root != null) { IPath path = getWorkspaceRelativePath(fullPath); - while (!path.isEmpty()) { + while (path.segmentCount() > 0) { IResource res = root.findMember(path); if (res != null) return res.getProject(); @@ -149,7 +150,7 @@ public class PathUtil { IWorkspaceRoot root = getWorkspaceRoot(); if (root != null) { IPath path = getWorkspaceRelativePath(fullPath); - while (!path.isEmpty()) { + while (path.segmentCount() > 0) { IResource res = root.findMember(path); if (res != null && res.exists() && (res.getType() == IResource.PROJECT || res.getType() == IResource.FOLDER)) return path;