1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-30 20:35:38 +02:00

Fix potential endless loops because of path.isEmpty()

This commit is contained in:
Markus Schorn 2006-06-30 09:28:30 +00:00
parent 12e256794c
commit 948ad54c3a
2 changed files with 6 additions and 4 deletions

View file

@ -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;

View file

@ -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;