-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: check variables before merge in finally block (#1592)
- Loading branch information
Showing
6 changed files
with
229 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatchFinally15.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package jadx.tests.integration.trycatch; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.tests.api.SmaliTest; | ||
|
||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; | ||
|
||
/** | ||
* Negative test case for finally extract (issue 1592). | ||
* Different registers incorrectly merged into one. | ||
*/ | ||
@SuppressWarnings({ "CommentedOutCode", "GrazieInspection" }) | ||
public class TestTryCatchFinally15 extends SmaliTest { | ||
|
||
// @formatter:off | ||
/* | ||
protected final Parcel test(int i, Parcel parcel) throws RemoteException { | ||
Parcel obtain = Parcel.obtain(); | ||
try { | ||
try { | ||
this.zza.transact(i, parcel, obtain, 0); | ||
obtain.readException(); | ||
return obtain; | ||
} catch (RuntimeException e) { | ||
obtain.recycle(); | ||
throw e; | ||
} | ||
} finally { | ||
parcel.recycle(); | ||
} | ||
} | ||
*/ | ||
// @formatter:on | ||
|
||
@Test | ||
public void test() { | ||
disableCompilation(); | ||
assertThat(getClassNodeFromSmali()) | ||
.code() | ||
.doesNotContain("parcel = Parcel.obtain();") | ||
.containsOne("this.zza.transact(i, parcel, obtain, 0);"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
jadx-core/src/test/smali/trycatch/TestTryCatchFinally15.smali
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
.class public Ltrycatch/TestTryCatchFinally15; | ||
.super Ljava/lang/Object; | ||
|
||
.implements Landroid/os/IInterface; | ||
|
||
.field private final zza:Landroid/os/IBinder; | ||
.field private final zzb:Ljava/lang/String; | ||
|
||
.method protected final test(ILandroid/os/Parcel;)Landroid/os/Parcel; | ||
.registers 6 | ||
.annotation system Ldalvik/annotation/Throws; | ||
value = { | ||
Landroid/os/RemoteException; | ||
} | ||
.end annotation | ||
|
||
.line 1 | ||
invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel; | ||
move-result-object v0 | ||
|
||
:try_start_4 | ||
iget-object v1, p0, Ltrycatch/TestTryCatchFinally15;->zza:Landroid/os/IBinder; | ||
const/4 v2, 0x0 | ||
|
||
.line 2 | ||
invoke-interface {v1, p1, p2, v0, v2}, Landroid/os/IBinder;->transact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z | ||
.line 3 | ||
invoke-virtual {v0}, Landroid/os/Parcel;->readException()V | ||
:try_end_d | ||
.catch Ljava/lang/RuntimeException; {:try_start_4 .. :try_end_d} :catch_13 | ||
.catchall {:try_start_4 .. :try_end_d} :catchall_11 | ||
|
||
.line 6 | ||
invoke-virtual {p2}, Landroid/os/Parcel;->recycle()V | ||
return-object v0 | ||
|
||
:catchall_11 | ||
move-exception p1 | ||
goto :goto_18 | ||
|
||
.line 5 | ||
:catch_13 | ||
move-exception p1 | ||
|
||
.line 4 | ||
:try_start_14 | ||
invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V | ||
|
||
.line 5 | ||
throw p1 | ||
:try_end_18 | ||
.catchall {:try_start_14 .. :try_end_18} :catchall_11 | ||
|
||
.line 6 | ||
:goto_18 | ||
invoke-virtual {p2}, Landroid/os/Parcel;->recycle()V | ||
|
||
.line 7 | ||
throw p1 | ||
.end method |