diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/ArrayDataPseudoInstruction.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/ArrayDataPseudoInstruction.java index b9d16ed2..f26f0aa7 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/ArrayDataPseudoInstruction.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/ArrayDataPseudoInstruction.java @@ -50,10 +50,15 @@ public class ArrayDataPseudoInstruction extends Instruction { throw new RuntimeException("There are not a whole number of " + elementWidth + " byte elements"); } + //write out padding, if necessary + if (out.getCursor() % 4 != 0) { + out.writeShort(0); + } + int elementCount = encodedValues.length / elementWidth; out.writeByte(0x00); - out.writeShort(0x03); + out.writeByte(0x03); out.writeShort(elementWidth); out.writeInt(elementCount); out.write(encodedValues); diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/PackedSwitchDataPseudoInstruction.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/PackedSwitchDataPseudoInstruction.java index c255029d..48283050 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/PackedSwitchDataPseudoInstruction.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/PackedSwitchDataPseudoInstruction.java @@ -50,6 +50,11 @@ public class PackedSwitchDataPseudoInstruction extends Instruction { "The maximum number of switch elements is 65535"); } + //write out padding, if necessary + if (out.getCursor() % 4 != 0) { + out.writeShort(0); + } + out.writeByte(0x00); out.writeByte(0x01); out.writeShort(targets.length); diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/SparseSwitchDataPseudoInstruction.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/SparseSwitchDataPseudoInstruction.java index 0dd97824..f35de81c 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/SparseSwitchDataPseudoInstruction.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/SparseSwitchDataPseudoInstruction.java @@ -58,6 +58,11 @@ public class SparseSwitchDataPseudoInstruction extends Instruction { "The maximum number of switch elements is 65535"); } + //write out padding, if necessary + if (out.getCursor() % 4 != 0) { + out.writeShort(0); + } + out.writeByte(0x00); out.writeByte(0x02); out.writeShort(targets.length);