From fc3b4a378e7017a59845bc5c47c9178680b6fe74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Fri, 22 Aug 2025 18:02:18 +0200 Subject: [PATCH] Fixed: #2520 Loop detection --- .../src/com/jpexs/decompiler/graph/Graph.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java index 84e0f69ec..8bf286b4c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java @@ -2804,7 +2804,8 @@ public class Graph { } //When some of breakcandidates pass through current stoppart, - //Remove other candidantes. + //Remove other candidantes. + Set removedX = new LinkedHashSet<>(); if (!currentLoop.stopParts.isEmpty()) { List bcsLeft = new ArrayList<>(); for (int c = 0; c < currentLoop.breakCandidates.size(); c++) { @@ -2816,10 +2817,10 @@ public class Graph { } if (!bcsLeft.isEmpty()) { - for (int c = currentLoop.breakCandidates.size() - 1; c >= 0; c--) { + for (int c = currentLoop.breakCandidates.size() - 1; c >= 0; c--) { if (!bcsLeft.contains(c)) { - currentLoop.breakCandidates.remove(c); - currentLoop.breakCandidatesLevels.remove(c); + GraphPart cand = currentLoop.breakCandidates.get(c); + removedX.add(cand); } } } @@ -2916,6 +2917,12 @@ public class Graph { } for (GraphPart cand : currentLoop.breakCandidates) { + if (removedX.contains(cand)) { + if (debugPrintLoopList) { + System.err.println("cand " + cand + " is removed"); + } + continue; + } if (bannedCandidates.contains(cand)) { if (debugPrintLoopList) { System.err.println("cand " + cand + " is banned");