Skip to content

Commit

Permalink
[DEX] Check zero width of array-data
Browse files Browse the repository at this point in the history
  • Loading branch information
REAndroid committed Jan 2, 2025
1 parent d078a40 commit 1d645d0
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/main/java/com/reandroid/dex/ins/InsArrayDataList.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class InsArrayDataList extends CountedBlockList<InsArrayDataList.ArrayDat
private final IntegerReference widthReference;

public InsArrayDataList(IntegerReference widthReference, IntegerReference countReference) {
super(new EntryCreator(widthReference), countReference);
super(new EntryCreator(widthReference), new WidthCheckingReference(widthReference, countReference));
this.widthReference = widthReference;
}

Expand Down Expand Up @@ -346,4 +346,30 @@ public ArrayDataEntry newInstance() {
return new ArrayDataEntry(this.width.get());
}
}
static class WidthCheckingReference implements IntegerReference {

private final IntegerReference width;
private final IntegerReference reference;

public WidthCheckingReference(IntegerReference width, IntegerReference reference) {
this.width = width;
this.reference = reference;
}
@Override
public int get() {
if (width.get() == 0) {
return 0;
}
return reference.get();
}

@Override
public void set(int value) {
reference.set(value);
}
@Override
public String toString() {
return Integer.toString(get());
}
}
}

0 comments on commit 1d645d0

Please sign in to comment.