From f6c7706102252daa0051b1f4a32d2fce3b17876e Mon Sep 17 00:00:00 2001 From: "JesusFreke@JesusFreke.com" Date: Wed, 23 Dec 2009 05:27:14 +0000 Subject: [PATCH] ensure the string index is <= 0xFFFF before writing a string-const instruction git-svn-id: https://smali.googlecode.com/svn/trunk@504 55b6fa8a-2a1e-11de-a435-ffa8d773f76a --- .../main/java/org/jf/dexlib/Code/Format/Instruction21c.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction21c.java b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction21c.java index 20c4fa64..bec647fe 100644 --- a/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction21c.java +++ b/dexlib/src/main/java/org/jf/dexlib/Code/Format/Instruction21c.java @@ -69,6 +69,10 @@ public class Instruction21c extends InstructionWithReference implements SingleRe } protected void writeInstruction(AnnotatedOutput out, int currentCodeOffset) { + if(opcode == Opcode.CONST_STRING && getReferencedItem().getIndex() > 0xFFFF) { + throw new RuntimeException("String offset is too large for const-string. Use string-const/jumbo instead."); + } + out.writeByte(opcode.value); out.writeByte(regA); out.writeShort(getReferencedItem().getIndex());