fix: properly traverse methods with synchronize blocks that have no clear exit (PR #1041)
This commit is contained in:
@@ -594,6 +594,8 @@ public class RegionMaker {
|
||||
List<BlockNode> list = BlockUtils.buildSimplePath(exitBlock);
|
||||
if (list.isEmpty() || !list.get(list.size() - 1).getSuccessors().isEmpty()) {
|
||||
stack.addExit(exitBlock);
|
||||
// we can still try using this as an exit block to make sure it's visited.
|
||||
exit = exitBlock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-2
@@ -2,7 +2,6 @@ package jadx.tests.integration.loops;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jadx.NotYetImplemented;
|
||||
import jadx.core.dex.nodes.ClassNode;
|
||||
import jadx.tests.api.IntegrationTest;
|
||||
|
||||
@@ -34,7 +33,6 @@ public class TestSynchronizedInEndlessLoop extends IntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotYetImplemented
|
||||
public void test() {
|
||||
ClassNode cls = getClassNode(TestCls.class);
|
||||
String code = cls.getCode().toString();
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package jadx.tests.integration.synchronize;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jadx.core.dex.nodes.ClassNode;
|
||||
import jadx.tests.api.SmaliTest;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
public class TestSynchronized5 extends SmaliTest {
|
||||
@Test
|
||||
public void test() {
|
||||
ClassNode cls = getClassNodeFromSmali();
|
||||
String code = cls.getCode().toString();
|
||||
|
||||
assertThat(code, containsString("1 != 0"));
|
||||
assertThat(code, containsString("System.gc();"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
.class public Lsynchronize/TestSynchronized5;
|
||||
.super Ljava/lang/Object;
|
||||
|
||||
.method public final get()V
|
||||
.registers 6
|
||||
|
||||
monitor-enter p0
|
||||
|
||||
:try_start_1
|
||||
|
||||
const/4 v0, 0
|
||||
|
||||
if-eqz v0, :cond_1
|
||||
|
||||
monitor-exit p0
|
||||
|
||||
return-void
|
||||
|
||||
:cond_1
|
||||
|
||||
monitor-exit p0
|
||||
:try_end_1
|
||||
.catchall {:try_start_1 .. :try_end_1} :catchall_1
|
||||
|
||||
monitor-enter p0
|
||||
|
||||
:try_start_2
|
||||
|
||||
const/4 v1, 1
|
||||
|
||||
if-eqz v1, :cond_2
|
||||
|
||||
invoke-static {}, Ljava/lang/System;->gc()V
|
||||
|
||||
:cond_2
|
||||
|
||||
monitor-exit p0
|
||||
:try_end_2
|
||||
.catchall {:try_start_2 .. :try_end_2} :catchall_2
|
||||
|
||||
return-void
|
||||
|
||||
:catchall_2
|
||||
move-exception v0
|
||||
|
||||
:try_start_3
|
||||
monitor-exit p0
|
||||
:try_end_3
|
||||
.catchall {:try_start_3 .. :try_end_3} :catchall_2
|
||||
|
||||
throw v0
|
||||
|
||||
:catchall_1
|
||||
move-exception v0
|
||||
|
||||
:try_start_4
|
||||
monitor-exit p0
|
||||
:try_end_4
|
||||
.catchall {:try_start_4 .. :try_end_4} :catchall_1
|
||||
|
||||
throw v0
|
||||
.end method
|
||||
Reference in New Issue
Block a user