summaryrefslogtreecommitdiffstats
path: root/src/de
diff options
context:
space:
mode:
authorStiver <stiver.mail@gmail.com>2014-08-13 22:04:51 +0200
committerStiver <stiver.mail@gmail.com>2014-08-13 22:04:51 +0200
commit53ad2b920ec63b1d5900357e9d4725f74031daa9 (patch)
tree9c0ecca97f2d7d257b08be10d095352cbb0c3dad /src/de
parentde249340fc5a0446701dcf8a117aa69ad6dd3f71 (diff)
downloadfernflower-53ad2b920ec63b1d5900357e9d4725f74031daa9.tar
fernflower-53ad2b920ec63b1d5900357e9d4725f74031daa9.tar.gz
fernflower-53ad2b920ec63b1d5900357e9d4725f74031daa9.tar.lz
fernflower-53ad2b920ec63b1d5900357e9d4725f74031daa9.tar.xz
fernflower-53ad2b920ec63b1d5900357e9d4725f74031daa9.zip
Fixed 'IDEA-128593: Wrong order of switch cases'
Diffstat (limited to 'src/de')
-rw-r--r--src/de/fernflower/modules/decompiler/stats/SwitchStatement.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/de/fernflower/modules/decompiler/stats/SwitchStatement.java b/src/de/fernflower/modules/decompiler/stats/SwitchStatement.java
index 21fdfcf..f3d2231 100644
--- a/src/de/fernflower/modules/decompiler/stats/SwitchStatement.java
+++ b/src/de/fernflower/modules/decompiler/stats/SwitchStatement.java
@@ -266,15 +266,20 @@ public class SwitchStatement extends Statement {
setPreds.remove(first);
if(!setPreds.isEmpty()) {
- Statement pred = setPreds.iterator().next(); // at most one predecessor node besides the head
- for(int j=index+1;j<nodes.size();j++) {
- if(nodes.get(j) == pred) {
+ Statement pred = setPreds.iterator().next(); // assumption: at most one predecessor node besides the head. May not hold true for obfuscated code.
+ for(int j=0;j<nodes.size();j++) {
+ if(j != (index - 1) && nodes.get(j) == pred) {
nodes.add(j+1, stat);
edges.add(j+1, edges.get(index));
- nodes.remove(index);
- edges.remove(index);
- index--;
+ if(j > index) {
+ nodes.remove(index);
+ edges.remove(index);
+ index--;
+ } else {
+ nodes.remove(index + 1);
+ edges.remove(index + 1);
+ }
break;
}
}