Merge pull request #49 from MultiplyByZer01/insert-on-empty

Prevent crash when calling insertInstruction() on empty MethodBody
This commit is contained in:
honfika
2017-03-12 11:38:18 +01:00
committed by GitHub

View File

@@ -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());