Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Use of while loop instead of for #977

Closed
bagipro opened this issue Sep 19, 2020 · 4 comments
Closed

[core] Use of while loop instead of for #977

bagipro opened this issue Sep 19, 2020 · 4 comments
Labels
bug Core Issues in jadx-core module

Comments

@bagipro
Copy link
Collaborator

bagipro commented Sep 19, 2020

Hey, please check class com.vkontakte.android.audio.contentprovider.AudioContentProvider

    public static void m51830a(android.content.Context context) {
        java.lang.String nameForUid = context.getPackageManager().getNameForUid(android.os.Binder.getCallingUid());
        java.lang.String[] strArr = p022g.p1646u.p1647b.t0.p1695f.AudioContentProviderConstants.f77052B;
        int length = strArr.length;
        int i = 0;
        while (i < length) {
            if (!android.text.TextUtils.equals(strArr[i], m51828a(nameForUid))) {
                i++;
            } else {
                return;
            }
        }
        throw new java.lang.SecurityException("Wrong caller");
    }

this is a pure for loop that should be decompiled like so

    public static void m51830a(android.content.Context context) {
        java.lang.String nameForUid = context.getPackageManager().getNameForUid(android.os.Binder.getCallingUid());
        java.lang.String[] strArr = p022g.p1646u.p1647b.t0.p1695f.AudioContentProviderConstants.f77052B;
        for (int i = 0; i < strArr.length; i++) {
            if (android.text.TextUtils.equals(strArr[i], m51828a(nameForUid))) {
                return;
            }
        }
        throw new java.lang.SecurityException("Wrong caller");
    }

or to an enhanced loop

    public static void m51830a(android.content.Context context) {
        java.lang.String nameForUid = context.getPackageManager().getNameForUid(android.os.Binder.getCallingUid());
        for (java.lang.String str : p022g.p1646u.p1647b.t0.p1695f.AudioContentProviderConstants.f77052B) {
            if (android.text.TextUtils.equals(str, m51828a(nameForUid))) {
                return;
            }
        }
        throw new java.lang.SecurityException("Wrong caller");
    }

APK: https://drive.google.com/file/d/1bfQf9vhvg0vmbVlr75J9wyMr0sMk1chZ/view?usp=sharing

@bagipro bagipro added bug Core Issues in jadx-core module labels Sep 19, 2020
@skylot
Copy link
Owner

skylot commented Sep 23, 2020

@sergey-wowwow fixed in commit 33f2c3f.

@skylot skylot closed this as completed Sep 23, 2020
@bagipro
Copy link
Collaborator Author

bagipro commented Sep 24, 2020

@skylot
I see that a bug was added in class kotlin.sequences.DropWhileSequence$iterator$1

package kotlin.sequences;

/*  JADX ERROR: NullPointerException in pass: ExtractFieldInit
    java.lang.NullPointerException
    	at jadx.core.utils.BlockUtils.isAllBlocksEmpty(BlockUtils.java:615)
    	at jadx.core.dex.visitors.ExtractFieldInit.getConstructorsList(ExtractFieldInit.java:241)
    	at jadx.core.dex.visitors.ExtractFieldInit.moveCommonFieldsInit(ExtractFieldInit.java:122)
    	at jadx.core.dex.visitors.ExtractFieldInit.visit(ExtractFieldInit.java:43)
    */
public final class DropWhileSequence$iterator$1 implements java.util.Iterator<T>, kotlin.jvm.internal.markers.KMappedMarker {
    private int dropState;
    private final java.util.Iterator<T> iterator;
    private T nextItem;
    final /* synthetic */ kotlin.sequences.DropWhileSequence this$0;

    /*  JADX ERROR: NullPointerException in pass: MethodInvokeVisitor
        java.lang.NullPointerException
        	at jadx.core.dex.visitors.MethodInvokeVisitor.visit(MethodInvokeVisitor.java:58)
        */
    /*  JADX ERROR: NullPointerException in pass: SimplifyVisitor
        java.lang.NullPointerException
        */
    public void remove(
/*
[8] Method generation error in method: kotlin.sequences.DropWhileSequence$iterator$1.remove():void, file: classes3.dex
    jadx.core.utils.exceptions.JadxRuntimeException: Method arg registers not loaded: kotlin.sequences.DropWhileSequence$iterator$1.remove():void, class status: PROCESS_COMPLETE
    	at jadx.core.dex.nodes.MethodNode.getArgRegs(MethodNode.java:266)
    	at jadx.core.codegen.MethodGen.addDefinition(MethodGen.java:132)
    	at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:340)
    	at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:298)
    	at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$3(ClassGen.java:267)
    	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
    	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
    
*/

    /*  JADX ERROR: NullPointerException in pass: SimplifyVisitor
        java.lang.NullPointerException
        */
    DropWhileSequence$iterator$1(
/*
[19] Method generation error in method: kotlin.sequences.DropWhileSequence$iterator$1.<init>(kotlin.sequences.DropWhileSequence):void, file: classes3.dex
    jadx.core.utils.exceptions.JadxRuntimeException: Method arg registers not loaded: kotlin.sequences.DropWhileSequence$iterator$1.<init>(kotlin.sequences.DropWhileSequence):void, class status: PROCESS_COMPLETE
    	at jadx.core.dex.nodes.MethodNode.getArgRegs(MethodNode.java:266)
    	at jadx.core.codegen.MethodGen.addDefinition(MethodGen.java:132)
    	at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:340)
    	at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:298)
    	at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$3(ClassGen.java:267)
    	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
    	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
    
*/

    /*  JADX ERROR: NullPointerException in pass: MethodInvokeVisitor
        java.lang.NullPointerException
        	at jadx.core.dex.visitors.MethodInvokeVisitor.visit(MethodInvokeVisitor.java:58)
        */
    /*  JADX ERROR: NullPointerException in pass: SimplifyVisitor
        java.lang.NullPointerException
        */
    public final java.util.Iterator<T> getIterator(
/*
[3] Method generation error in method: kotlin.sequences.DropWhileSequence$iterator$1.getIterator():java.util.Iterator<T>, file: classes3.dex
    jadx.core.utils.exceptions.JadxRuntimeException: Method arg registers not loaded: kotlin.sequences.DropWhileSequence$iterator$1.getIterator():java.util.Iterator<T>, class status: PROCESS_COMPLETE
    	at jadx.core.dex.nodes.MethodNode.getArgRegs(MethodNode.java:266)
    	at jadx.core.codegen.MethodGen.addDefinition(MethodGen.java:132)
    	at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:340)
    	at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:298)
    	at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$3(ClassGen.java:267)
    	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
    	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
    
*/

    /*  JADX ERROR: NullPointerException in pass: MethodInvokeVisitor
        java.lang.NullPointerException
        	at jadx.core.dex.visitors.MethodInvokeVisitor.visit(MethodInvokeVisitor.java:58)
        */
    /*  JADX ERROR: NullPointerException in pass: SimplifyVisitor
        java.lang.NullPointerException
        */
    public final int getDropState(
/*
[3] Method generation error in method: kotlin.sequences.DropWhileSequence$iterator$1.getDropState():int, file: classes3.dex
    jadx.core.utils.exceptions.JadxRuntimeException: Method arg registers not loaded: kotlin.sequences.DropWhileSequence$iterator$1.getDropState():int, class status: PROCESS_COMPLETE
    	at jadx.core.dex.nodes.MethodNode.getArgRegs(MethodNode.java:266)
    	at jadx.core.codegen.MethodGen.addDefinition(MethodGen.java:132)
    	at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:340)
    	at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:298)
    	at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$3(ClassGen.java:267)
    	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
    	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
    
*/

    /*  JADX ERROR: NullPointerException in pass: MethodInvokeVisitor
        java.lang.NullPointerException
        	at jadx.core.dex.visitors.MethodInvokeVisitor.visit(MethodInvokeVisitor.java:58)
        */
    /*  JADX ERROR: NullPointerException in pass: SimplifyVisitor
        java.lang.NullPointerException
        */
    public final void setDropState(
/*
[3] Method generation error in method: kotlin.sequences.DropWhileSequence$iterator$1.setDropState(int):void, file: classes3.dex
    jadx.core.utils.exceptions.JadxRuntimeException: Method arg registers not loaded: kotlin.sequences.DropWhileSequence$iterator$1.setDropState(int):void, class status: PROCESS_COMPLETE
    	at jadx.core.dex.nodes.MethodNode.getArgRegs(MethodNode.java:266)
    	at jadx.core.codegen.MethodGen.addDefinition(MethodGen.java:132)
    	at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:340)
    	at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:298)
    	at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$3(ClassGen.java:267)
    	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
    	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
    
*/

    /*  JADX ERROR: NullPointerException in pass: MethodInvokeVisitor
        java.lang.NullPointerException
        	at jadx.core.dex.visitors.MethodInvokeVisitor.visit(MethodInvokeVisitor.java:58)
        */
    /*  JADX ERROR: NullPointerException in pass: SimplifyVisitor
        java.lang.NullPointerException
        */
    public final T getNextItem(
/*
[3] Method generation error in method: kotlin.sequences.DropWhileSequence$iterator$1.getNextItem():T, file: classes3.dex
    jadx.core.utils.exceptions.JadxRuntimeException: Method arg registers not loaded: kotlin.sequences.DropWhileSequence$iterator$1.getNextItem():T, class status: PROCESS_COMPLETE
    	at jadx.core.dex.nodes.MethodNode.getArgRegs(MethodNode.java:266)
    	at jadx.core.codegen.MethodGen.addDefinition(MethodGen.java:132)
    	at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:340)
    	at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:298)
    	at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$3(ClassGen.java:267)
    	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
    	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
    
*/

    /*  JADX ERROR: NullPointerException in pass: MethodInvokeVisitor
        java.lang.NullPointerException
        	at jadx.core.dex.visitors.MethodInvokeVisitor.visit(MethodInvokeVisitor.java:58)
        */
    /*  JADX ERROR: NullPointerException in pass: SimplifyVisitor
        java.lang.NullPointerException
        */
    public final void setNextItem(
/*
[3] Method generation error in method: kotlin.sequences.DropWhileSequence$iterator$1.setNextItem(T):void, file: classes3.dex
    jadx.core.utils.exceptions.JadxRuntimeException: Method arg registers not loaded: kotlin.sequences.DropWhileSequence$iterator$1.setNextItem(T):void, class status: PROCESS_COMPLETE
    	at jadx.core.dex.nodes.MethodNode.getArgRegs(MethodNode.java:266)
    	at jadx.core.codegen.MethodGen.addDefinition(MethodGen.java:132)
    	at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:340)
    	at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:298)
    	at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$3(ClassGen.java:267)
    	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
    	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
    
*/

    /*  JADX ERROR: NullPointerException in pass: MethodInvokeVisitor
        java.lang.NullPointerException
        	at jadx.core.dex.visitors.MethodInvokeVisitor.visit(MethodInvokeVisitor.java:58)
        */
    /*  JADX ERROR: NullPointerException in pass: SimplifyVisitor
        java.lang.NullPointerException
        */
    private final void drop(
/*
[42] Method generation error in method: kotlin.sequences.DropWhileSequence$iterator$1.drop():void, file: classes3.dex
    jadx.core.utils.exceptions.JadxRuntimeException: Method arg registers not loaded: kotlin.sequences.DropWhileSequence$iterator$1.drop():void, class status: PROCESS_COMPLETE
    	at jadx.core.dex.nodes.MethodNode.getArgRegs(MethodNode.java:266)
    	at jadx.core.codegen.MethodGen.addDefinition(MethodGen.java:132)
    	at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:340)
    	at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:298)
    	at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$3(ClassGen.java:267)
    	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
    	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
    
*/

    /*  JADX ERROR: NullPointerException in pass: MethodInvokeVisitor
        java.lang.NullPointerException
        	at jadx.core.dex.visitors.MethodInvokeVisitor.visit(MethodInvokeVisitor.java:58)
        */
    /*  JADX ERROR: NullPointerException in pass: SimplifyVisitor
        java.lang.NullPointerException
        */
    public T next(
/*
[29] Method generation error in method: kotlin.sequences.DropWhileSequence$iterator$1.next():T, file: classes3.dex
    jadx.core.utils.exceptions.JadxRuntimeException: Method arg registers not loaded: kotlin.sequences.DropWhileSequence$iterator$1.next():T, class status: PROCESS_COMPLETE
    	at jadx.core.dex.nodes.MethodNode.getArgRegs(MethodNode.java:266)
    	at jadx.core.codegen.MethodGen.addDefinition(MethodGen.java:132)
    	at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:340)
    	at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:298)
    	at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$3(ClassGen.java:267)
    	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
    	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
    
*/

    /*  JADX ERROR: NullPointerException in pass: MethodInvokeVisitor
        java.lang.NullPointerException
        	at jadx.core.dex.visitors.MethodInvokeVisitor.visit(MethodInvokeVisitor.java:58)
        */
    /*  JADX ERROR: NullPointerException in pass: SimplifyVisitor
        java.lang.NullPointerException
        */
    public boolean hasNext(
/*
[24] Method generation error in method: kotlin.sequences.DropWhileSequence$iterator$1.hasNext():boolean, file: classes3.dex
    jadx.core.utils.exceptions.JadxRuntimeException: Method arg registers not loaded: kotlin.sequences.DropWhileSequence$iterator$1.hasNext():boolean, class status: PROCESS_COMPLETE
    	at jadx.core.dex.nodes.MethodNode.getArgRegs(MethodNode.java:266)
    	at jadx.core.codegen.MethodGen.addDefinition(MethodGen.java:132)
    	at jadx.core.codegen.ClassGen.addMethodCode(ClassGen.java:340)
    	at jadx.core.codegen.ClassGen.addMethod(ClassGen.java:298)
    	at jadx.core.codegen.ClassGen.lambda$addInnerClsAndMethods$3(ClassGen.java:267)
    	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    	at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
    	at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
    
*/
}

APK: https://drive.google.com/file/d/1qC3tlWs9AtPBpyS6iU9kcSphLryfJOxi/view?usp=sharing

skylot added a commit that referenced this issue Sep 27, 2020
Signed-off-by: Skylot <skylot@gmail.com>
@skylot
Copy link
Owner

skylot commented Sep 27, 2020

@sergey-wowwow fixed! That was a multi-threaded issue caused by missing synchronization. Thanks for the report!

@bagipro
Copy link
Collaborator Author

bagipro commented Sep 28, 2020

@skylot
Thanks! Works perfect now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Core Issues in jadx-core module
Projects
None yet
Development

No branches or pull requests

2 participants