未验证 提交 faa205a4 编写于 作者: J Jonas Konrad 提交者: GitHub

fix: process exception handler when handler block is start of a new try block (PR #1036)

上级 3a6d645e
......@@ -113,12 +113,11 @@ public class BlockSplitter extends AbstractVisitor {
}
}
}
if (insn.contains(AType.EXC_HANDLER)) {
processExceptionHandler(mth, curBlock, insn);
}
if (insn.contains(AFlag.TRY_ENTER)) {
curBlock = insertSplitterBlock(mth, blocksMap, curBlock, insn, startNew);
} else if (insn.contains(AType.EXC_HANDLER)) {
processExceptionHandler(mth, curBlock, insn);
blocksMap.put(insn.getOffset(), curBlock);
curBlock.getInstructions().add(insn);
} else {
blocksMap.put(insn.getOffset(), curBlock);
curBlock.getInstructions().add(insn);
......
package jadx.tests.integration.trycatch;
import org.junit.jupiter.api.Test;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.SmaliTest;
import static jadx.tests.api.utils.JadxMatchers.containsOne;
import static org.hamcrest.MatcherAssert.assertThat;
public class TestTryWithEmptyCatchTriple extends SmaliTest {
@Test
public void test() {
ClassNode cls = getClassNodeFromSmaliWithPkg("trycatch", "TestTryWithEmptyCatchTriple");
String code = cls.getCode().toString();
assertThat(code, containsOne("} catch (Error unused) {"));
assertThat(code, containsOne("} catch (Error unused2) {"));
assertThat(code, containsOne("} catch (Error unused3) {"));
}
}
.class public Ltrycatch/TestTryWithEmptyCatchTriple;
.super Ljava/lang/Object;
.field static field:[I
.method static test()V
.registers 3
const/4 v0, 0x1
:try_start_1
sget-object v1, Ltrycatch/TestTryWithEmptyCatchTriple;->field:[I
const/4 v2, 0x0
aput v0, v1, v2
:try_end_1
.catch Ljava/lang/Error; {:try_start_1 .. :try_end_1} :catch_1
:catch_1
sget-object v1, Ltrycatch/TestTryWithEmptyCatchTriple;->field:[I
array-length v1, v1
new-array v1, v1, [I
sput-object v1, Ltrycatch/TestTryWithEmptyCatchTriple;->field:[I
:try_start_2
sget-object v1, Ltrycatch/TestTryWithEmptyCatchTriple;->field:[I
const/4 v2, 0x0
aput v0, v1, v2
:try_end_2
.catch Ljava/lang/Error; {:try_start_2 .. :try_end_2} :catch_2
:catch_2
:try_start_3
sget-object v0, Ltrycatch/TestTryWithEmptyCatchTriple;->field:[I
const/4 v1, 0x0
const/4 v2, 0x2
aput v2, v0, v1
:try_end_3
.catch Ljava/lang/Error; {:try_start_3 .. :try_end_3} :catch_3
:catch_3
return-void
.end method
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册