Skip to content

Commit

Permalink
Fix problems with removing tryblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebFenton committed Dec 12, 2015
1 parent ec10e01 commit 12d3fca
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ public void removeInstruction(MethodLocation location) {
int index = location.getIndex();
implementation.removeInstruction(index);
removeEmptyTryCatchBlocks();

rebuildGraph();
}

Expand Down Expand Up @@ -426,7 +425,6 @@ private void removeEmptyTryCatchBlocks() {
// Get location using reflection to avoid null check.
MethodLocation start = getLocation(tryBlock.start);
MethodLocation end = getLocation(tryBlock.end);

if (start == null || end == null || start.getCodeAddress() == end.getCodeAddress()) {
// Empty try block!

Expand All @@ -435,13 +433,13 @@ private void removeEmptyTryCatchBlocks() {
// of the try block, which could cause null pointer exceptions.
removeIndexes.add(index);

if (start != null) {
List<Label> remove = new ArrayList<Label>();
remove.add(tryBlock.start);
remove.add(tryBlock.end);
remove.add(tryBlock.exceptionHandler.getHandler());
start.getLabels().removeAll(remove);
}
// I think dexlib correctly, gracefully handles removing orphaned labels
// if (start != null) {
// List<Label> remove = new LinkedList<Label>();
// remove.add(tryBlock.start);
// remove.add(tryBlock.end);
// start.getLabels().removeAll(remove);
// }
}
}

Expand Down

0 comments on commit 12d3fca

Please sign in to comment.