From 51ceb60ea46d1f0fc8b3a99708abd94d14ba7cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Tue, 2 Feb 2021 20:31:06 +0100 Subject: [PATCH] Try..catch..finally in ASC2 - correct default branch detection --- .../flash/abc/avm2/graph/AVM2Graph.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index 41e11459a..685b9e2db 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -328,16 +328,25 @@ public class AVM2Graph extends Graph { if (tryPartRefs.size() == 1) { GraphPart beforeTryPart = tryPartRefs.get(0); if (beforeTryPart.getHeight() > 2) { - if (avm2code.code.get(beforeTryPart.end).definition instanceof SetLocalTypeIns) { - int setLocalRegister = ((SetLocalTypeIns) avm2code.code.get(beforeTryPart.end).definition).getRegisterId(avm2code.code.get(beforeTryPart.end)); - if (setLocalRegister == switchedReg) { - if (avm2code.code.get(beforeTryPart.end - 1).definition instanceof PushByteIns) { - if (switchPart != null) { - defaultPushByte = avm2code.code.get(beforeTryPart.end - 1).operands[0]; + int pos = beforeTryPart.end; + while (beforeTryPart.start <= pos) { + if (avm2code.code.get(pos).definition instanceof SetLocalTypeIns) { + int setLocalRegister = ((SetLocalTypeIns) avm2code.code.get(pos).definition).getRegisterId(avm2code.code.get(beforeTryPart.end)); + if (setLocalRegister == switchedReg) { + if (avm2code.code.get(pos - 1).definition instanceof PushByteIns) { + if (switchPart != null) { + defaultPushByte = avm2code.code.get(pos - 1).operands[0]; + } } } + break; + } else if (avm2code.code.get(pos).definition instanceof DebugLineIns) { + pos--; + } else { + break; } } + } } }