From 2904f4060318acebfa5a1c8d43b362dcfdd063b0 Mon Sep 17 00:00:00 2001 From: "JesusFreke@JesusFreke.com" Date: Wed, 23 Dec 2009 23:46:18 +0000 Subject: [PATCH] Fix an issue when the current address immediatly after an AdvancePC debug instruction doesn't point to an instruction git-svn-id: https://smali.googlecode.com/svn/trunk@515 55b6fa8a-2a1e-11de-a435-ffa8d773f76a --- dexlib/src/main/java/org/jf/dexlib/CodeItem.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dexlib/src/main/java/org/jf/dexlib/CodeItem.java b/dexlib/src/main/java/org/jf/dexlib/CodeItem.java index 2954f5f9..68ebd388 100644 --- a/dexlib/src/main/java/org/jf/dexlib/CodeItem.java +++ b/dexlib/src/main/java/org/jf/dexlib/CodeItem.java @@ -639,6 +639,16 @@ public class CodeItem extends Item { } int newOffset = newOffsetsByOriginalOffset.get(address*2, -1); + + //The address might not point to an actual instruction in some cases, for example, if an AdvancePC + //instruction was inserted just before a "special" instruction, to fix up the offsets for a previous + //instruction replacement. + //In this case, it should be safe to skip, because there will be another AdvancePC/SpecialOpcode that will + //bump up the address to point to a valid instruction before anything (line/local/etc.) is emitted + if (newOffset == -1) { + return; + } + assert newOffset != -1; newOffset = newOffset / 2;