diff --git a/CHANGELOG.md b/CHANGELOG.md index b52c82e8b..60a77d063 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,7 @@ All notable changes to this project will be documented in this file. - [#2143] FLA Export / Sound playback - taking MP3 initial latency into account - [#2153] FLA Export - sound streams were limited to first stream block - [#2163] FLA Export - maintain sound export settings for streams +- [#2162] Debugger - ignore (warn) invalid jumps when injecting debug info ### Changed - [#2120] Exported assets no longer take names from assigned classes if there is more than 1 assigned class @@ -3366,6 +3367,7 @@ Major version of SWF to XML export changed to 2. [#2143]: https://www.free-decompiler.com/flash/issues/2143 [#2153]: https://www.free-decompiler.com/flash/issues/2153 [#2163]: https://www.free-decompiler.com/flash/issues/2163 +[#2162]: https://www.free-decompiler.com/flash/issues/2162 [#2120]: https://www.free-decompiler.com/flash/issues/2120 [#1130]: https://www.free-decompiler.com/flash/issues/1130 [#1220]: https://www.free-decompiler.com/flash/issues/1220 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java index 2b6eadede..09a480331 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java @@ -544,6 +544,7 @@ public class ScriptPack extends AS3ClassTreeItem { } for (int bodyIndex : bodyToPosToLine.keySet()) { + System.err.println("bi="+bodyIndex); List delIns = new ArrayList<>(); MethodBody b = abc.bodies.get(bodyIndex); @@ -605,6 +606,9 @@ public class ScriptPack extends AS3ClassTreeItem { if (addedLines.contains(line)) { continue; } + if (!origPosToNewPos.containsKey(i + dpos)) { + continue; + } addedLines.add(line); logger.log(Level.FINE, "Script {0}: Insert debugline({1}) at pos {2} to body {3}", new Object[]{path, line, i, bodyIndex}); code2.add(origPosToNewPos.get(i + dpos), new AVM2Instruction(0, AVM2Instructions.DebugLine, new int[]{line})); @@ -634,20 +638,32 @@ public class ScriptPack extends AS3ClassTreeItem { int changedOperand; if (ins.definition instanceof IfTypeIns) { targetAddr = ins.getTargetAddress(); - changedAddr = mapOffsets.get(targetAddr); - changedOperand = (int) (changedAddr - adr - 4); - ins.operands[0] = changedOperand; + if (mapOffsets.containsKey(targetAddr)) { + changedAddr = mapOffsets.get(targetAddr); + changedOperand = (int) (changedAddr - adr - 4); + ins.operands[0] = changedOperand; + } else { + logger.log(Level.WARNING, "Invalid jump target in script {0}, bodyIndex {1}", new Object[]{toString(), bodyIndex}); + } } if (ins.definition instanceof LookupSwitchIns) { targetAddr = ins.getAddress() + ins.operands[0]; - changedAddr = mapOffsets.get(targetAddr); - changedOperand = (int) (changedAddr - adr); - ins.operands[0] = changedOperand; - for (int k = 2; k < ins.operands.length; k++) { - targetAddr = ins.getAddress() + ins.operands[k]; + if (mapOffsets.containsKey(targetAddr)) { changedAddr = mapOffsets.get(targetAddr); changedOperand = (int) (changedAddr - adr); - ins.operands[k] = changedOperand; + ins.operands[0] = changedOperand; + } else { + logger.log(Level.WARNING, "Invalid jump target in script {0}, bodyIndex {1}", new Object[]{toString(), bodyIndex}); + } + for (int k = 2; k < ins.operands.length; k++) { + targetAddr = ins.getAddress() + ins.operands[k]; + if (mapOffsets.containsKey(targetAddr)) { + changedAddr = mapOffsets.get(targetAddr); + changedOperand = (int) (changedAddr - adr); + ins.operands[k] = changedOperand; + } else { + logger.log(Level.WARNING, "Invalid jump target in script {0}, bodyIndex {1}", new Object[]{toString(), bodyIndex}); + } } } ins.setAddress(adr);