mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-10-23 05:31:02 +00:00
Merge remote-tracking branch 'origin/GP-4530-dragonmacher-dominance-algo-npe'
This commit is contained in:
commit
a36671d9d3
|
@ -232,7 +232,7 @@ public class ChkDominanceAlgorithm<V, E extends GEdge<V>> extends AbstractDomina
|
|||
}
|
||||
|
||||
V dominator = getImmediateDominator(v);
|
||||
if (!Objects.equals(dominator, v)) {
|
||||
if (dominator != null && !Objects.equals(dominator, v)) {
|
||||
dg.addEdge(new DefaultGEdge<>(dominator, v));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -320,6 +320,31 @@ public class GraphAlgorithmsTest extends AbstractGraphAlgorithmsTest {
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testDominance_GetDominatorGraph_WithDummySource() throws CancelledException {
|
||||
|
||||
TestV v1 = vertex(1);
|
||||
TestV v2 = vertex(2);
|
||||
TestV v3 = vertex(3);
|
||||
TestV v4 = vertex(4);
|
||||
|
||||
//
|
||||
// 3 sources; 1 sink
|
||||
//
|
||||
// This will trigger the algorithm to use a unifying dummy node for the source. This used
|
||||
// to lead to a NullPointerException when trying to process the dummy as a dominator.
|
||||
//
|
||||
edge(v2, v1);
|
||||
edge(v3, v1);
|
||||
edge(v4, v1);
|
||||
|
||||
GDirectedGraph<TestV, GEdge<TestV>> dg =
|
||||
GraphAlgorithms.findDominanceTree(g, TaskMonitor.DUMMY);
|
||||
|
||||
assertContainsEdgesExactly(dg);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDominance_GetDominators_Complicated() throws CancelledException {
|
||||
|
||||
|
@ -1924,7 +1949,7 @@ public class GraphAlgorithmsTest extends AbstractGraphAlgorithmsTest {
|
|||
|
||||
assertThat(entries.size(), is(3));
|
||||
assertThat(entries, hasItems(v1, v4));
|
||||
assertThat(entries, hasItem(isOneOf(v5, v6, v7)));
|
||||
assertThat(entries, hasItem(is(oneOf(v5, v6, v7))));
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user