tinker icon indicating copy to clipboard operation
tinker copied to clipboard

生成补丁包时出现 ArrayIndexOutOfBoundsException

Open TestPlanB opened this issue 8 months ago • 0 comments

框架版本

1.9.15.1 都有问题

复现场景: AGP 7.4 && isProtectedApp = true 情况下

问题堆栈

Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 7 out of bounds for length 7 at org.jf.dexlib2.builder.BuilderMutableMethodImplementation.mapCodeAddressToIndex(BuilderMutableMethodImplementation.java:586) at org.jf.dexlib2.builder.BuilderMutableMethodImplementation.<init>(BuilderMutableMethodImplementation.java:201) at com.tencent.tinker.build.decoder.DexDiffDecoder.generateChangedClassesDexFile(DexDiffDecoder.java:470) at com.tencent.tinker.build.decoder.DexDiffDecoder.onAllPatchesEnd(DexDiffDecoder.java:249) at com.tencent.tinker.build.decoder.ApkDecoder.patch(ApkDecoder.java:128) at com.tencent.tinker.build.patch.Runner.tinkerPatch(Runner.java:69)

问题源码

isProtectedApp 为true后,会走到创建 BuilderMutableMethodImplementation 流程,这个对象初始化时调用的mapCodeAddressToIndex方法,出现codeAddress数组越界

private int mapCodeAddressToIndex(@Nonnull int[] codeAddressToIndex, int codeAddress) { int index; do { index = codeAddressToIndex[codeAddress]; if (index < 0) { codeAddress--; } else { return index; } } while (true); }

TestPlanB avatar Apr 25 '25 06:04 TestPlanB