mirror of
https://github.com/revanced/smali.git
synced 2025-06-13 04:27:38 +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) {
|
public void copyTo(DexFile dexFile, CachedIntegerValueField _copy) {
|
||||||
EncodedCatchHandlerReference copy = (EncodedCatchHandlerReference)_copy;
|
EncodedCatchHandlerReference copy = (EncodedCatchHandlerReference)_copy;
|
||||||
EncodedCatchHandler copiedItem = copy.getEncodedCatchHandlerList().getByOffset(
|
EncodedCatchHandler copiedItem = copy.getEncodedCatchHandlerList().intern(encodedCatchHandler);
|
||||||
encodedCatchHandler.getOffsetInList());
|
|
||||||
copy.setReference(copiedItem);
|
copy.setReference(copiedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void writeTo(AnnotatedOutput out) {
|
public void writeTo(AnnotatedOutput out) {
|
||||||
cacheValue(encodedCatchHandler.getOffsetInList());
|
cacheValue(encodedCatchHandler.getOffsetInList());
|
||||||
|
|
||||||
@ -237,9 +235,12 @@ public class CodeItem extends OffsettedItem<CodeItem> {
|
|||||||
|
|
||||||
public class EncodedCatchHandlerList extends CompositeField<EncodedCatchHandlerList> {
|
public class EncodedCatchHandlerList extends CompositeField<EncodedCatchHandlerList> {
|
||||||
private boolean fieldPresent = false;
|
private boolean fieldPresent = false;
|
||||||
|
//this field is only valid when reading a dex file in
|
||||||
protected HashMap<Integer, EncodedCatchHandler> itemsByOffset =
|
protected HashMap<Integer, EncodedCatchHandler> itemsByOffset =
|
||||||
new HashMap<Integer, EncodedCatchHandler>();
|
new HashMap<Integer, EncodedCatchHandler>();
|
||||||
|
|
||||||
|
protected HashMap<EncodedCatchHandler, EncodedCatchHandler> uniqueItems = null;
|
||||||
|
|
||||||
private final DexFile dexFile;
|
private final DexFile dexFile;
|
||||||
|
|
||||||
public EncodedCatchHandler getByOffset(int offset) {
|
public EncodedCatchHandler getByOffset(int offset) {
|
||||||
@ -249,8 +250,27 @@ public class CodeItem extends OffsettedItem<CodeItem> {
|
|||||||
itemsByOffset.put(offset, encodedCatchHandler);
|
itemsByOffset.put(offset, encodedCatchHandler);
|
||||||
}
|
}
|
||||||
return 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) {
|
public EncodedCatchHandlerList(final DexFile dexFile) {
|
||||||
@ -318,6 +338,7 @@ public class CodeItem extends OffsettedItem<CodeItem> {
|
|||||||
super.copyTo(dexFile, copy);
|
super.copyTo(dexFile, copy);
|
||||||
copy.fieldPresent = fieldPresent;
|
copy.fieldPresent = fieldPresent;
|
||||||
copy.itemsByOffset.clear();
|
copy.itemsByOffset.clear();
|
||||||
|
int offset = 0;
|
||||||
for (EncodedCatchHandler encodedCatchHandler: copy.listField.list) {
|
for (EncodedCatchHandler encodedCatchHandler: copy.listField.list) {
|
||||||
copy.itemsByOffset.put(encodedCatchHandler.offset, encodedCatchHandler);
|
copy.itemsByOffset.put(encodedCatchHandler.offset, encodedCatchHandler);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user