fix: prevent endless loop in path cross search (#1360)

This commit is contained in:
Skylot
2022-02-01 14:32:44 +00:00
parent 06c7415827
commit d71f3e09df
@@ -709,6 +709,7 @@ public class BlockUtils {
return oneBlock;
}
BitSet combinedDF = newBlocksBitSet(mth);
int k = mth.getBasicBlocks().size();
while (true) {
// collect dom frontier blocks from current set until only one block left
forEachBlockFromBitSet(mth, domFrontBS, block -> {
@@ -726,6 +727,10 @@ public class BlockUtils {
if (cardinality == 0) {
return null;
}
if (k-- < 0) {
mth.addWarnComment("Path cross not found for " + blocks + ", limit reached: " + mth.getBasicBlocks().size());
return null;
}
// replace domFrontBS with combinedDF
domFrontBS.clear();
domFrontBS.or(combinedDF);