Skip to content

Commit

Permalink
Fix IOB in ExtractMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
Su5eD committed Apr 7, 2024
1 parent b6315e6 commit 07174a5
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ private static Patch.Result recreateLocalVariables(ClassNode classNode, MethodNo
TransformParameters patch = TransformParameters.builder()
.chain(b -> IntStream.range(paramLocalStart, capturedLocals.paramLocalEnd())
.filter(i -> !used.contains(i))
.boxed().sorted(Collections.reverseOrder())
.forEach(b::remove))
.build();
Patch.Result result = patch.apply(classNode, methodNode, methodContext, context);
Expand All @@ -277,9 +278,11 @@ private static Patch.Result recreateLocalVariables(ClassNode classNode, MethodNo
copy.invisibleAnnotations = null;
methodNode.instructions = new InsnList();
// Remove used locals from the original method, as we'll be providing them ourselves
TransformParameters.Builder cleanupBuilder = TransformParameters.builder();
IntStream.range(paramLocalStart, paramLocalStart + used.size()).forEach(cleanupBuilder::remove);
TransformParameters cleanupPatch = cleanupBuilder.build();
TransformParameters cleanupPatch = TransformParameters.builder()
.chain(b -> IntStream.range(paramLocalStart, paramLocalStart + used.size()).boxed()
.sorted(Collections.reverseOrder())
.forEach(b::remove))
.build();
Patch.Result cleanupResult = cleanupPatch.apply(classNode, methodNode, methodContext, context);
if (cleanupResult == Patch.Result.PASS) {
return Patch.Result.PASS;
Expand Down

0 comments on commit 07174a5

Please sign in to comment.