From 2c85203985093ed65b75e1c228b9919bee1fc5c5 Mon Sep 17 00:00:00 2001 From: MultiplyByZer0 Date: Sat, 11 Mar 2017 22:50:30 -0400 Subject: [PATCH] Prevent crash when calling insertInstruction() on empty MethodBody If an AVM2Code object is empty, and we attempt to insert an instruction, the method will execute code.get(-1) and throw an exception. This commit handles the situation. --- .../src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 19c774f43..248eaefa7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -2371,7 +2371,9 @@ public class AVM2Code implements Cloneable { pos = code.size(); } final int byteCount = instruction.getBytesLength(); - if (pos == code.size()) { + if (code.size() == 0) { + instruction.setAddress(0); + } else if (pos == code.size()) { instruction.setAddress(code.get(pos - 1).getAddress() + code.get(pos - 1).getBytesLength()); } else { instruction.setAddress(code.get(pos).getAddress());