avoid potential null ptr deref (Coverity)

This commit is contained in:
Terence Parr 2013-08-31 16:32:59 -07:00
parent 9420672520
commit 1febc36e15
1 changed files with 3 additions and 1 deletions

View File

@ -97,7 +97,9 @@ public class Graph<T> {
n = tNode;
if ( !visited.contains(n) ) break;
}
DFS(n, visited, sorted);
if (n!=null) { // if at least one unvisited
DFS(n, visited, sorted);
}
}
return sorted;
}