Skip to content

Commit

Permalink
Fix IOBE in DynamicModifyVarAtReturnPatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Su5eD committed May 10, 2024
1 parent 8a428a5 commit 503aa2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public Optional<Integer> apply(MethodContext methodContext, ClassNode classNode,
List<AbstractInsnNode> cleanReturnInsns = findReturnInsns(cleanTarget.methodNode());
List<AbstractInsnNode> dirtyReturnInsns = findReturnInsns(dirtyTarget.methodNode());

if (ordinal < cleanReturnInsns.size()) {
if (ordinal < cleanReturnInsns.size() && cleanReturnInsns.size() != dirtyReturnInsns.size()) {
AbstractInsnNode cleanInsn = cleanReturnInsns.get(ordinal);
InstructionMatcher original = new InstructionMatcher(cleanInsn, findReturnPrecedingInsns(cleanInsn), List.of());
List<InstructionMatcher> dirtyMatchers = dirtyReturnInsns.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ private static Pair<AbstractInsnNode, Integer> getTargetPair(ClassNode classNode
if (targetInsns.isEmpty()) {
return null;
}
AbstractInsnNode targetInsn = targetInsns.get(ordinal == -1 ? targetInsns.size() - 1 : ordinal);
int index = ordinal == -1 ? targetInsns.size() - 1 : ordinal;
if (index >= targetInsns.size()) {
return null;
}
AbstractInsnNode targetInsn = targetInsns.get(index);
// Find modified variable
LocalVariableDiscriminator discriminator = LocalVariableDiscriminator.parse(methodContext.methodAnnotation().unwrap());
InjectionInfo injectionInfo = MockMixinRuntime.forInjectionInfo(classNode.name, injectionTarget.classNode().name, context.environment());
Expand Down

0 comments on commit 503aa2c

Please sign in to comment.