Fix an issue with nop opcodes with a non-null second byte

This commit is contained in:
Ben Gruver 2013-11-26 17:34:52 -08:00
parent ee3fb21461
commit d7cd52308e
4 changed files with 15 additions and 7 deletions

View File

@ -69,7 +69,10 @@ public class Opcodes {
case 0x300:
return Opcode.ARRAY_PAYLOAD;
default:
return opcodesByValue[opcodeValue];
if (opcodeValue >= 0 && opcodeValue < opcodesByValue.length) {
return opcodesByValue[opcodeValue];
}
return null;
}
}
}

View File

@ -43,7 +43,12 @@ public class DexBackedUnknownInstruction extends DexBackedInstruction implements
super(dexFile, Opcode.NOP, instructionStart);
}
@Override public short getOriginalOpcode() {
return (short)dexFile.readUbyte(instructionStart);
@Override public int getOriginalOpcode() {
int opcode = dexFile.readUbyte(instructionStart);
if (opcode == 0) {
opcode = dexFile.readUshort(instructionStart);
}
return opcode;
}
}

View File

@ -32,5 +32,5 @@
package org.jf.dexlib2.iface.instruction.formats;
public interface UnknownInstruction extends Instruction10x {
short getOriginalOpcode();
int getOriginalOpcode();
}

View File

@ -38,9 +38,9 @@ import org.jf.dexlib2.iface.instruction.formats.UnknownInstruction;
public class ImmutableUnknownInstruction extends ImmutableInstruction implements UnknownInstruction {
public static final Format FORMAT = Format.Format10x;
protected final short originalOpcode;
protected final int originalOpcode;
public ImmutableUnknownInstruction(short originalOpcode) {
public ImmutableUnknownInstruction(int originalOpcode) {
super(Opcode.NOP);
this.originalOpcode = originalOpcode;
}
@ -53,5 +53,5 @@ public class ImmutableUnknownInstruction extends ImmutableInstruction implements
}
@Override public Format getFormat() { return FORMAT; }
@Override public short getOriginalOpcode() { return originalOpcode; }
@Override public int getOriginalOpcode() { return originalOpcode; }
}