mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-02 22:05:44 +02:00
Fix potential endless loops because of path.isEmpty()
This commit is contained in:
parent
12e256794c
commit
948ad54c3a
2 changed files with 6 additions and 4 deletions
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - initial API and implementation
|
* QNX Software Systems - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.browser;
|
package org.eclipse.cdt.core.browser;
|
||||||
|
|
||||||
|
@ -136,7 +137,7 @@ public class PathUtil {
|
||||||
IWorkspaceRoot root = getWorkspaceRoot();
|
IWorkspaceRoot root = getWorkspaceRoot();
|
||||||
if (root != null) {
|
if (root != null) {
|
||||||
IPath path = getWorkspaceRelativePath(fullPath);
|
IPath path = getWorkspaceRelativePath(fullPath);
|
||||||
while (!path.isEmpty()) {
|
while (path.segmentCount() > 0) {
|
||||||
IResource res = root.findMember(path);
|
IResource res = root.findMember(path);
|
||||||
if (res != null)
|
if (res != null)
|
||||||
return CoreModel.getDefault().create(res.getProject());
|
return CoreModel.getDefault().create(res.getProject());
|
||||||
|
@ -151,7 +152,7 @@ public class PathUtil {
|
||||||
IWorkspaceRoot root = getWorkspaceRoot();
|
IWorkspaceRoot root = getWorkspaceRoot();
|
||||||
if (root != null) {
|
if (root != null) {
|
||||||
IPath path = getWorkspaceRelativePath(fullPath);
|
IPath path = getWorkspaceRelativePath(fullPath);
|
||||||
while (!path.isEmpty()) {
|
while (path.segmentCount() > 0) {
|
||||||
IResource res = root.findMember(path);
|
IResource res = root.findMember(path);
|
||||||
if (res != null && res.exists() && (res.getType() == IResource.PROJECT || res.getType() == IResource.FOLDER))
|
if (res != null && res.exists() && (res.getType() == IResource.PROJECT || res.getType() == IResource.FOLDER))
|
||||||
return path;
|
return path;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - initial API and implementation
|
* QNX Software Systems - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.utils;
|
package org.eclipse.cdt.utils;
|
||||||
|
|
||||||
|
@ -134,7 +135,7 @@ public class PathUtil {
|
||||||
IWorkspaceRoot root = getWorkspaceRoot();
|
IWorkspaceRoot root = getWorkspaceRoot();
|
||||||
if (root != null) {
|
if (root != null) {
|
||||||
IPath path = getWorkspaceRelativePath(fullPath);
|
IPath path = getWorkspaceRelativePath(fullPath);
|
||||||
while (!path.isEmpty()) {
|
while (path.segmentCount() > 0) {
|
||||||
IResource res = root.findMember(path);
|
IResource res = root.findMember(path);
|
||||||
if (res != null)
|
if (res != null)
|
||||||
return res.getProject();
|
return res.getProject();
|
||||||
|
@ -149,7 +150,7 @@ public class PathUtil {
|
||||||
IWorkspaceRoot root = getWorkspaceRoot();
|
IWorkspaceRoot root = getWorkspaceRoot();
|
||||||
if (root != null) {
|
if (root != null) {
|
||||||
IPath path = getWorkspaceRelativePath(fullPath);
|
IPath path = getWorkspaceRelativePath(fullPath);
|
||||||
while (!path.isEmpty()) {
|
while (path.segmentCount() > 0) {
|
||||||
IResource res = root.findMember(path);
|
IResource res = root.findMember(path);
|
||||||
if (res != null && res.exists() && (res.getType() == IResource.PROJECT || res.getType() == IResource.FOLDER))
|
if (res != null && res.exists() && (res.getType() == IResource.PROJECT || res.getType() == IResource.FOLDER))
|
||||||
return path;
|
return path;
|
||||||
|
|
Loading…
Add table
Reference in a new issue