mirror of
https://github.com/revanced/smali.git
synced 2025-05-10 03:14:31 +02:00
Add a check to Item.getOffset() and getIndex() to ensure the item has been placed
This commit is contained in:
parent
b71c12967b
commit
1ffc028a3b
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
package org.jf.dexlib;
|
package org.jf.dexlib;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import org.jf.dexlib.Util.AlignmentUtils;
|
import org.jf.dexlib.Util.AlignmentUtils;
|
||||||
import org.jf.dexlib.Util.AnnotatedOutput;
|
import org.jf.dexlib.Util.AnnotatedOutput;
|
||||||
import org.jf.dexlib.Util.ExceptionWithContext;
|
import org.jf.dexlib.Util.ExceptionWithContext;
|
||||||
@ -191,6 +192,8 @@ public abstract class Item<T extends Item> implements Comparable<T> {
|
|||||||
* @return the offset in the dex file where this item is located
|
* @return the offset in the dex file where this item is located
|
||||||
*/
|
*/
|
||||||
public int getOffset() {
|
public int getOffset() {
|
||||||
|
Preconditions.checkState(offset != -1,
|
||||||
|
"The offset is not set until the DexFile containing this item is placed.");
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,6 +201,8 @@ public abstract class Item<T extends Item> implements Comparable<T> {
|
|||||||
* @return the index of this item within the item's containing section
|
* @return the index of this item within the item's containing section
|
||||||
*/
|
*/
|
||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
|
Preconditions.checkState(index != -1,
|
||||||
|
"The index is not set until the DexFile containing this item is placed.");
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user