diff --git a/projects/core/src/main/java/dan200/computercraft/core/filesystem/MemoryMount.java b/projects/core/src/main/java/dan200/computercraft/core/filesystem/MemoryMount.java index c8e09a586..2db0154b6 100644 --- a/projects/core/src/main/java/dan200/computercraft/core/filesystem/MemoryMount.java +++ b/projects/core/src/main/java/dan200/computercraft/core/filesystem/MemoryMount.java @@ -275,9 +275,9 @@ public final class MemoryMount extends AbstractInMemoryMount= backing.length) return -1; + if (position >= entry.length) return -1; - var remaining = Math.min(backing.length - (int) position, destination.remaining()); + var remaining = Math.min(entry.length - (int) position, destination.remaining()); destination.put(backing, (int) position, remaining); position += remaining; return remaining; @@ -285,7 +285,7 @@ public final class MemoryMount extends AbstractInMemoryMount= entry.length) { + if (capacity >= contents.length) { var newCapacity = Math.max(capacity, contents.length << 1); contents = entry.contents = Arrays.copyOf(contents, newCapacity); }