mirror of
https://github.com/revanced/smali.git
synced 2025-06-12 04:17:36 +02:00
Fixed an issue where all catch items in a method were using the same set of handlers, instead of using the correct set of handlers for each region
git-svn-id: https://smali.googlecode.com/svn/trunk@194 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
@ -211,12 +211,10 @@ public class CodeItem extends OffsettedItem<CodeItem> {
|
||||
|
||||
public void copyTo(DexFile dexFile, CachedIntegerValueField _copy) {
|
||||
EncodedCatchHandlerReference copy = (EncodedCatchHandlerReference)_copy;
|
||||
EncodedCatchHandler copiedItem = copy.getEncodedCatchHandlerList().getByOffset(
|
||||
encodedCatchHandler.getOffsetInList());
|
||||
EncodedCatchHandler copiedItem = copy.getEncodedCatchHandlerList().intern(encodedCatchHandler);
|
||||
copy.setReference(copiedItem);
|
||||
}
|
||||
|
||||
|
||||
public void writeTo(AnnotatedOutput out) {
|
||||
cacheValue(encodedCatchHandler.getOffsetInList());
|
||||
|
||||
@ -237,9 +235,12 @@ public class CodeItem extends OffsettedItem<CodeItem> {
|
||||
|
||||
public class EncodedCatchHandlerList extends CompositeField<EncodedCatchHandlerList> {
|
||||
private boolean fieldPresent = false;
|
||||
//this field is only valid when reading a dex file in
|
||||
protected HashMap<Integer, EncodedCatchHandler> itemsByOffset =
|
||||
new HashMap<Integer, EncodedCatchHandler>();
|
||||
|
||||
protected HashMap<EncodedCatchHandler, EncodedCatchHandler> uniqueItems = null;
|
||||
|
||||
private final DexFile dexFile;
|
||||
|
||||
public EncodedCatchHandler getByOffset(int offset) {
|
||||
@ -249,8 +250,27 @@ public class CodeItem extends OffsettedItem<CodeItem> {
|
||||
itemsByOffset.put(offset, encodedCatchHandler);
|
||||
}
|
||||
return encodedCatchHandler;
|
||||
}
|
||||
|
||||
public EncodedCatchHandler intern(EncodedCatchHandler item) {
|
||||
if (uniqueItems == null) {
|
||||
buildInternedItemMap();
|
||||
}
|
||||
EncodedCatchHandler encodedCatchHandler = uniqueItems.get(item);
|
||||
if (encodedCatchHandler == null) {
|
||||
encodedCatchHandler = new EncodedCatchHandler(dexFile, -1);
|
||||
catchHandlerList.add(encodedCatchHandler);
|
||||
item.copyTo(dexFile, encodedCatchHandler);
|
||||
uniqueItems.put(encodedCatchHandler, encodedCatchHandler);
|
||||
}
|
||||
return encodedCatchHandler;
|
||||
}
|
||||
|
||||
private void buildInternedItemMap() {
|
||||
uniqueItems = new HashMap<EncodedCatchHandler, EncodedCatchHandler>();
|
||||
for (EncodedCatchHandler item: catchHandlerList) {
|
||||
uniqueItems.put(item, item);
|
||||
}
|
||||
}
|
||||
|
||||
public EncodedCatchHandlerList(final DexFile dexFile) {
|
||||
@ -318,6 +338,7 @@ public class CodeItem extends OffsettedItem<CodeItem> {
|
||||
super.copyTo(dexFile, copy);
|
||||
copy.fieldPresent = fieldPresent;
|
||||
copy.itemsByOffset.clear();
|
||||
int offset = 0;
|
||||
for (EncodedCatchHandler encodedCatchHandler: copy.listField.list) {
|
||||
copy.itemsByOffset.put(encodedCatchHandler.offset, encodedCatchHandler);
|
||||
}
|
||||
|
Reference in New Issue
Block a user