diff --git a/definition/src/main/java/org/sinytra/adapter/patch/transformer/dynamic/DynamicInjectorOrdinalPatch.java b/definition/src/main/java/org/sinytra/adapter/patch/transformer/dynamic/DynamicInjectorOrdinalPatch.java index 2caca77..a1375d2 100644 --- a/definition/src/main/java/org/sinytra/adapter/patch/transformer/dynamic/DynamicInjectorOrdinalPatch.java +++ b/definition/src/main/java/org/sinytra/adapter/patch/transformer/dynamic/DynamicInjectorOrdinalPatch.java @@ -170,7 +170,7 @@ public Optional apply(MethodContext methodContext, ClassNode classNode, List cleanReturnInsns = findReturnInsns(cleanTarget.methodNode()); List 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 dirtyMatchers = dirtyReturnInsns.stream() diff --git a/definition/src/main/java/org/sinytra/adapter/patch/transformer/dynamic/DynamicModifyVarAtReturnPatch.java b/definition/src/main/java/org/sinytra/adapter/patch/transformer/dynamic/DynamicModifyVarAtReturnPatch.java index d32d765..52e0233 100644 --- a/definition/src/main/java/org/sinytra/adapter/patch/transformer/dynamic/DynamicModifyVarAtReturnPatch.java +++ b/definition/src/main/java/org/sinytra/adapter/patch/transformer/dynamic/DynamicModifyVarAtReturnPatch.java @@ -145,7 +145,11 @@ private static Pair 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());