From 0d4443a19a591c506a4e9214f96003da210e2d86 Mon Sep 17 00:00:00 2001 From: Ben Gruver Date: Thu, 21 Mar 2019 13:41:00 -0700 Subject: [PATCH] Gracefully deal with code addresses that are out of range in MutableMethodImplementation The code addresses in debug info items are not verified, and may be out of bounds. If this happens, we just clamp them to the maximum code address. --- .../org/jf/dexlib2/builder/MutableMethodImplementation.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dexlib2/src/main/java/org/jf/dexlib2/builder/MutableMethodImplementation.java b/dexlib2/src/main/java/org/jf/dexlib2/builder/MutableMethodImplementation.java index a77ae253..3e4925ea 100644 --- a/dexlib2/src/main/java/org/jf/dexlib2/builder/MutableMethodImplementation.java +++ b/dexlib2/src/main/java/org/jf/dexlib2/builder/MutableMethodImplementation.java @@ -473,6 +473,9 @@ public class MutableMethodImplementation implements MethodImplementation { private int mapCodeAddressToIndex(@Nonnull int[] codeAddressToIndex, int codeAddress) { int index; do { + if (codeAddress >= codeAddressToIndex.length) { + codeAddress = codeAddressToIndex.length - 1; + } index = codeAddressToIndex[codeAddress]; if (index < 0) { codeAddress--;