summaryrefslogtreecommitdiff
path: root/io/util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'io/util.ts')
-rw-r--r--io/util.ts1
1 files changed, 1 insertions, 0 deletions
diff --git a/io/util.ts b/io/util.ts
index 3266e5018..185732b36 100644
--- a/io/util.ts
+++ b/io/util.ts
@@ -4,6 +4,7 @@ import { Buffer, Reader } from "deno";
// from `src`.
// Returns the number of bytes copied.
export function copyBytes(dst: Uint8Array, src: Uint8Array, off = 0): number {
+ off = Math.max(0, Math.min(off, dst.byteLength));
const r = dst.byteLength - off;
if (src.byteLength > r) {
src = src.subarray(0, r);