From e039a5a9af95c8e9f9f56a9056eedf344ee763f0 Mon Sep 17 00:00:00 2001 From: Skylot Date: Tue, 1 May 2018 19:32:55 +0300 Subject: [PATCH] core: don't process debug info if offset is incorrect (#259) --- jadx-core/src/main/java/jadx/core/dex/nodes/DexNode.java | 5 +++++ .../main/java/jadx/core/dex/visitors/DebugInfoVisitor.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/jadx-core/src/main/java/jadx/core/dex/nodes/DexNode.java b/jadx-core/src/main/java/jadx/core/dex/nodes/DexNode.java index 3d8311cdc..c407d1098 100644 --- a/jadx-core/src/main/java/jadx/core/dex/nodes/DexNode.java +++ b/jadx-core/src/main/java/jadx/core/dex/nodes/DexNode.java @@ -190,6 +190,10 @@ public class DexNode implements IDexNode { return dexBuf.open(offset); } + public boolean checkOffset(int dataOffset) { + return dataOffset >= 0 && dataOffset < dexBuf.getLength(); + } + @Override public RootNode root() { return root; @@ -208,4 +212,5 @@ public class DexNode implements IDexNode { public String toString() { return "DEX"; } + } diff --git a/jadx-core/src/main/java/jadx/core/dex/visitors/DebugInfoVisitor.java b/jadx-core/src/main/java/jadx/core/dex/visitors/DebugInfoVisitor.java index 39eeb1a9d..622508cf3 100644 --- a/jadx-core/src/main/java/jadx/core/dex/visitors/DebugInfoVisitor.java +++ b/jadx-core/src/main/java/jadx/core/dex/visitors/DebugInfoVisitor.java @@ -22,7 +22,7 @@ public class DebugInfoVisitor extends AbstractVisitor { public void visit(MethodNode mth) throws JadxException { try { int debugOffset = mth.getDebugInfoOffset(); - if (debugOffset > 0) { + if (debugOffset > 0 && mth.dex().checkOffset(debugOffset)) { processDebugInfo(mth, debugOffset); } } catch (Exception e) {