From 54029940495bffaead570de20aa18ceb35d1778a Mon Sep 17 00:00:00 2001 From: fhaag95 Date: Tue, 12 Dec 2023 09:44:10 +0100 Subject: [PATCH] Fix bug with variable substitution in recipes --- src/main/java/de/usd/cstchef/Utils.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/usd/cstchef/Utils.java b/src/main/java/de/usd/cstchef/Utils.java index e3de0e6..908b82e 100644 --- a/src/main/java/de/usd/cstchef/Utils.java +++ b/src/main/java/de/usd/cstchef/Utils.java @@ -173,8 +173,11 @@ public static ByteArray replaceVariablesByte(ByteArray bytes) { public static ByteArray insertAtOffset(ByteArray input, int start, int end, ByteArray newValue) { ByteArray prefix = input.subArray(0, start); - ByteArray rest = input.subArray(end, input.length()); - + ByteArray rest = ByteArray.byteArray(""); + if (end != input.length()){ + rest = input.subArray(end, input.length()); + } + ByteArray output = prefix.withAppended(newValue).withAppended(rest); return output; }