Fixed 1597987: NPE in new DaaRule

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4805 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Sven Jacob
2006-11-16 22:27:25 +00:00
parent 2462c9637b
commit 110797a22e

View File

@ -290,12 +290,14 @@ public class DAAPathFinder {
private int countLoops() {
DefaultMutableTreeNode treeNode = stack.getLastLeaf();
int counter = 0;
int childCount = treeNode.getParent().getChildCount();
for (int i = 0; i < childCount; i++) {
DefaultMutableTreeNode tNode = (DefaultMutableTreeNode) treeNode.getParent().getChildAt(i);
PathElement e = (PathElement) tNode.getUserObject();
if (e != null && !e.isPseudoPathElement()) {
counter++;
if (treeNode.getParent() != null) {
int childCount = treeNode.getParent().getChildCount();
for (int i = 0; i < childCount; i++) {
DefaultMutableTreeNode tNode = (DefaultMutableTreeNode) treeNode.getParent().getChildAt(i);
PathElement e = (PathElement) tNode.getUserObject();
if (e != null && !e.isPseudoPathElement()) {
counter++;
}
}
}
return counter;